package com.example.core.service.impl;

import com.example.core.dao.DatabaseDao;
import com.example.core.entity.*;
import com.example.core.service.DatabaseService;
import com.example.core.utils.CoreIndexEnum;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;

import javax.annotation.Resource;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@Transactional(rollbackFor = Exception.class)
@Service("DatabaseService")
public class DatabaseServiceImpl implements DatabaseService {

    @Resource
    DatabaseDao databaseDao;

    @Override
    public void handleJxsRepTotalInfo(String yearId, String quarterId, List<DealerForm> dealerList, Map<String, Object> carMap,
                                      Map<String, Object> usedMap, Map<String, Object> saleMap, Map<String, Object> globalMap) {

        List<JxsRepTotalInfo> resultList = new ArrayList<>();//累计
        ObjectMapper objectMapper = new ObjectMapper();
        JxsRepTotalInfo jxsRepTotalInfo;

        //全国
        jxsRepTotalInfo = new JxsRepTotalInfo();
        jxsRepTotalInfo.setId(getUUID());//ID
        jxsRepTotalInfo.setYearId(yearId);//年份
        jxsRepTotalInfo.setQuarterId(quarterId);//季度
        jxsRepTotalInfo.setRangeType(4);//rangeType
        jxsRepTotalInfo.setAsAbsorptivity(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get售后吸收率());
        jxsRepTotalInfo.setAsOutput(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店售后产值());
        jxsRepTotalInfo.setEnterNum(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get售后进厂台次平均单店());
        jxsRepTotalInfo.setGml2RateTax(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get新车毛利Ⅱ对新车利润贡献率());
        jxsRepTotalInfo.setEbt(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).getEBT本年累计税前净利润率());

        resultList.add(jxsRepTotalInfo);

        //大区
        ArrayList<AfterSaleIndex> afterSaleArea = (ArrayList<AfterSaleIndex>) saleMap.get("售后_区域累计");
        ArrayList<NewCarIndex> carArea = (ArrayList<NewCarIndex>) carMap.get("新车_区域累计");
        ArrayList<GlobalIndex> globalArea = (ArrayList<GlobalIndex>) globalMap.get("总体_区域累计");
        for (int i = 0; i < afterSaleArea.size(); i++) {
            jxsRepTotalInfo = new JxsRepTotalInfo();
            jxsRepTotalInfo.setId(getUUID());//ID
            jxsRepTotalInfo.setYearId(yearId);//年份
            jxsRepTotalInfo.setQuarterId(quarterId);//季度
            jxsRepTotalInfo.setRangeType(3);//rangeType
            jxsRepTotalInfo.setJxsRegionId(afterSaleArea.get(i).get区域ID());
            jxsRepTotalInfo.setAsAbsorptivity(afterSaleArea.get(i).get售后吸收率());
            jxsRepTotalInfo.setAsOutput(afterSaleArea.get(i).get平均单店售后产值());
            jxsRepTotalInfo.setEnterNum(afterSaleArea.get(i).get售后进厂台次平均单店());
            jxsRepTotalInfo.setGml2RateTax(carArea.get(i).get新车毛利Ⅱ对新车利润贡献率());
            jxsRepTotalInfo.setEbt(globalArea.get(i).getEBT本年累计税前净利润率());

            resultList.add(jxsRepTotalInfo);
        }

        //经销商
        ArrayList<AfterSaleIndex> afterSaleDealer = (ArrayList<AfterSaleIndex>) saleMap.get("售后_经销商累计");
        ArrayList<NewCarIndex> carDealer = (ArrayList<NewCarIndex>) carMap.get("新车_经销商累计");
        ArrayList<GlobalIndex> globalDealer = (ArrayList<GlobalIndex>) globalMap.get("总体_经销商累计");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepTotalInfo = new JxsRepTotalInfo();
            jxsRepTotalInfo.setId(getUUID());//ID
            jxsRepTotalInfo.setYearId(yearId);//年份
            jxsRepTotalInfo.setQuarterId(quarterId);//季度
            jxsRepTotalInfo.setRangeType(0);//rangeType
            jxsRepTotalInfo.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepTotalInfo.setJxsRegionId(dealerList.get(i).getRegionName());
            jxsRepTotalInfo.setAsAbsorptivity(afterSaleDealer.get(i).get售后吸收率());
            jxsRepTotalInfo.setAsOutput(afterSaleDealer.get(i).get平均单店售后产值());
            jxsRepTotalInfo.setEnterNum(afterSaleDealer.get(i).get售后进厂台次平均单店());
            jxsRepTotalInfo.setGml2RateTax(carDealer.get(i).get新车毛利Ⅱ对新车利润贡献率());
            jxsRepTotalInfo.setEbt(globalDealer.get(i).getEBT本年累计税前净利润率());

            resultList.add(jxsRepTotalInfo);
        }

        //表1EBT
        BigDecimal loss = BigDecimal.valueOf(resultList.stream().filter(
                o -> o.getRangeType().equals(0) && o.getEbt().compareTo(new BigDecimal("0")) > 0).count())
                .divide(BigDecimal.valueOf(dealerList.size()), 4, BigDecimal.ROUND_HALF_EVEN);
        resultList.get(0).setProfitPer(loss);
        resultList.get(0).setLossPre(BigDecimal.valueOf(Long.parseLong("1")).subtract(loss));


        BigDecimal lossEast = BigDecimal.valueOf(resultList.stream().filter(o -> o.getRangeType().equals(0)
                && "东区".equals(o.getJxsRegionId()) && o.getEbt().compareTo(new BigDecimal("0")) > 0).count())
                .divide(BigDecimal.valueOf(dealerList.stream().filter(o -> "东区".equals(o.getRegionName())).count()), 4, BigDecimal.ROUND_HALF_EVEN);
        resultList.get(1).setProfitPer(lossEast);
        resultList.get(1).setLossPre(BigDecimal.valueOf(Long.parseLong("1")).subtract(lossEast));

        BigDecimal lossSouth = BigDecimal.valueOf(resultList.stream().filter(o -> o.getRangeType().equals(0)
                && "南区".equals(o.getJxsRegionId()) && o.getEbt().compareTo(new BigDecimal("0")) > 0).count())
                .divide(BigDecimal.valueOf(dealerList.stream().filter(o -> "南区".equals(o.getRegionName())).count()), 4, BigDecimal.ROUND_HALF_EVEN);
        resultList.get(2).setProfitPer(lossSouth);
        resultList.get(2).setLossPre(BigDecimal.valueOf(Long.parseLong("1")).subtract(lossSouth));

        BigDecimal lossWest = BigDecimal.valueOf(resultList.stream().filter(o -> o.getRangeType().equals(0)
                && "西区".equals(o.getJxsRegionId()) && o.getEbt().compareTo(new BigDecimal("0")) > 0).count())
                .divide(BigDecimal.valueOf(dealerList.stream().filter(o -> "西区".equals(o.getRegionName())).count()), 4, BigDecimal.ROUND_HALF_EVEN);
        resultList.get(3).setProfitPer(lossWest);
        resultList.get(3).setLossPre(BigDecimal.valueOf(Long.parseLong("1")).subtract(lossWest));

        BigDecimal lossNorth = BigDecimal.valueOf(resultList.stream().filter(o -> o.getRangeType().equals(0)
                && "北区".equals(o.getJxsRegionId()) && o.getEbt().compareTo(new BigDecimal("0")) > 0).count())
                .divide(BigDecimal.valueOf(dealerList.stream().filter(o -> "北区".equals(o.getRegionName())).count()), 4, BigDecimal.ROUND_HALF_EVEN);
        resultList.get(4).setProfitPer(lossNorth);
        resultList.get(4).setLossPre(BigDecimal.valueOf(Long.parseLong("1")).subtract(lossNorth));

//        BigDecimal lossCentre = BigDecimal.valueOf(resultList.stream().filter(o -> o.getRangeType().equals(0)
//                && "中区".equals(o.getJxsRegionId()) && o.getEbt().compareTo(new BigDecimal("0")) > 0).count())
//                .divide(BigDecimal.valueOf(dealerList.stream().filter(o -> "中区".equals(o.getRegionName())).count()), 4, BigDecimal.ROUND_HALF_EVEN);
//        resultList.get(5).setProfitPer(lossCentre);
//        resultList.get(5).setLossPre(BigDecimal.valueOf(Long.parseLong("1")).subtract(lossCentre));


        List<JxsRepTotalInfo> tempList = new ArrayList<>();//季度

        //6.全国
        jxsRepTotalInfo = new JxsRepTotalInfo();
        jxsRepTotalInfo.setId(getUUID());//ID
        jxsRepTotalInfo.setYearId(yearId);//年份
        jxsRepTotalInfo.setQuarterId(quarterId);//季度
        jxsRepTotalInfo.setRangeType(4);//rangeType
        jxsRepTotalInfo.setEbt(objectMapper.convertValue(globalMap.get("总体_全国"), GlobalIndex.class).get税前净利润率());

        tempList.add(jxsRepTotalInfo);

        //6.大区
        ArrayList<GlobalIndex> globalAreaTemp = (ArrayList<GlobalIndex>) globalMap.get("总体_区域");
        for (int i = 0; i < afterSaleArea.size(); i++) {
            jxsRepTotalInfo = new JxsRepTotalInfo();
            jxsRepTotalInfo.setId(getUUID());//ID
            jxsRepTotalInfo.setYearId(yearId);//年份
            jxsRepTotalInfo.setQuarterId(quarterId);//季度
            jxsRepTotalInfo.setRangeType(3);//rangeType
            jxsRepTotalInfo.setJxsRegionId(globalAreaTemp.get(i).get区域ID());
            jxsRepTotalInfo.setEbt(globalAreaTemp.get(i).get税前净利润率());

            tempList.add(jxsRepTotalInfo);
        }

        //6.经销商
        ArrayList<GlobalIndex> globalDealerTemp = (ArrayList<GlobalIndex>) globalMap.get("总体_经销商");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepTotalInfo = new JxsRepTotalInfo();
            jxsRepTotalInfo.setId(getUUID());//ID
            jxsRepTotalInfo.setYearId(yearId);//年份
            jxsRepTotalInfo.setQuarterId(quarterId);//季度
            jxsRepTotalInfo.setRangeType(0);//rangeType
            jxsRepTotalInfo.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepTotalInfo.setJxsRegionId(dealerList.get(i).getRegionName());
            jxsRepTotalInfo.setEbt(globalDealerTemp.get(i).get税前净利润率());

            tempList.add(jxsRepTotalInfo);
        }

        List<JxsRepRateProp> propList = new ArrayList<>();
        JxsRepRateProp jxsRepRateProp;

        //6.全国当前季度
        List<BigDecimal> countryProp = getPropList(tempList, dealerList, "全国");
        jxsRepRateProp = new JxsRepRateProp();
        jxsRepRateProp.setId(getUUID());//ID
        jxsRepRateProp.setYearId(yearId);
        jxsRepRateProp.setQuarterId(quarterId);
        jxsRepRateProp.setRangeType(4);
        jxsRepRateProp.setStatisType(1);
        jxsRepRateProp.setSubsection1(countryProp.get(0));
        jxsRepRateProp.setSubsection2(countryProp.get(1));
        jxsRepRateProp.setSubsection3(countryProp.get(2));
        jxsRepRateProp.setSubsection4(countryProp.get(3));
        jxsRepRateProp.setSubsection5(countryProp.get(4));
        jxsRepRateProp.setSubsection6(countryProp.get(5));
        jxsRepRateProp.setSubsection7(countryProp.get(6));

        propList.add(jxsRepRateProp);

        //6.全国累计
        List<BigDecimal> countryPropTotal = getPropList(resultList, dealerList, "全国");
        jxsRepRateProp = new JxsRepRateProp();
        jxsRepRateProp.setId(getUUID());//ID
        jxsRepRateProp.setYearId(yearId);
        jxsRepRateProp.setQuarterId(quarterId);
        jxsRepRateProp.setRangeType(4);
        jxsRepRateProp.setStatisType(0);
        jxsRepRateProp.setSubsection1(countryPropTotal.get(0));
        jxsRepRateProp.setSubsection2(countryPropTotal.get(1));
        jxsRepRateProp.setSubsection3(countryPropTotal.get(2));
        jxsRepRateProp.setSubsection4(countryPropTotal.get(3));
        jxsRepRateProp.setSubsection5(countryPropTotal.get(4));
        jxsRepRateProp.setSubsection6(countryPropTotal.get(5));
        jxsRepRateProp.setSubsection7(countryPropTotal.get(6));

        propList.add(jxsRepRateProp);

        //6.大区当前季度
//        List<String> regionArry = Arrays.asList("东区", "南区", "西区", "北区", "中区");
        List<String> regionArry = Arrays.asList("东区", "南区", "西区", "北区");
        for (int i = 0; i < regionArry.size(); i++) {
            String region = regionArry.get(i);


            List<BigDecimal> result = getPropList(tempList, dealerList, region);
            jxsRepRateProp = new JxsRepRateProp();
            jxsRepRateProp.setId(getUUID());//ID
            jxsRepRateProp.setYearId(yearId);
            jxsRepRateProp.setQuarterId(quarterId);
            jxsRepRateProp.setRangeType(3);
            jxsRepRateProp.setStatisType(1);
            if ("东区".equals(region)) {
                jxsRepRateProp.setJxsRegionId("e662790a-c722-11ea-b945-7b7148722317");
            } else if ("南区".equals(region)) {
                jxsRepRateProp.setJxsRegionId("e6633c5f-c722-11ea-b945-7b7148722317");
            } else if ("西区".equals(region)) {
                jxsRepRateProp.setJxsRegionId("e6636371-c722-11ea-b945-7b7148722317");
            } else if ("北区".equals(region)) {
                jxsRepRateProp.setJxsRegionId("e663154c-c722-11ea-b945-7b7148722317");
            }
//            else if ("中区".equals(region)) {
//                jxsRepRateProp.setJxsRegionId("e662a01b-c722-11ea-b945-7b7148722317");
//            }

            jxsRepRateProp.setSubsection1(result.get(0));
            jxsRepRateProp.setSubsection2(result.get(1));
            jxsRepRateProp.setSubsection3(result.get(2));
            jxsRepRateProp.setSubsection4(result.get(3));
            jxsRepRateProp.setSubsection5(result.get(4));
            jxsRepRateProp.setSubsection6(result.get(5));
            jxsRepRateProp.setSubsection7(result.get(6));

            propList.add(jxsRepRateProp);

        }

        //6.大区累计
        for (int i = 0; i < regionArry.size(); i++) {
            String region = regionArry.get(i);
            List<BigDecimal> result = getPropList(resultList, dealerList, region);
            jxsRepRateProp = new JxsRepRateProp();
            jxsRepRateProp.setId(getUUID());//ID
            jxsRepRateProp.setYearId(yearId);
            jxsRepRateProp.setQuarterId(quarterId);
            jxsRepRateProp.setRangeType(3);
            jxsRepRateProp.setStatisType(0);
            if ("东区".equals(region)) {
                jxsRepRateProp.setJxsRegionId("e662790a-c722-11ea-b945-7b7148722317");
            } else if ("南区".equals(region)) {
                jxsRepRateProp.setJxsRegionId("e6633c5f-c722-11ea-b945-7b7148722317");
            } else if ("西区".equals(region)) {
                jxsRepRateProp.setJxsRegionId("e6636371-c722-11ea-b945-7b7148722317");
            } else if ("北区".equals(region)) {
                jxsRepRateProp.setJxsRegionId("e663154c-c722-11ea-b945-7b7148722317");
            }
//            else if ("中区".equals(region)) {
//                jxsRepRateProp.setJxsRegionId("e662a01b-c722-11ea-b945-7b7148722317");
//            }
            jxsRepRateProp.setSubsection1(result.get(0));
            jxsRepRateProp.setSubsection2(result.get(1));
            jxsRepRateProp.setSubsection3(result.get(2));
            jxsRepRateProp.setSubsection4(result.get(3));
            jxsRepRateProp.setSubsection5(result.get(4));
            jxsRepRateProp.setSubsection6(result.get(5));
            jxsRepRateProp.setSubsection7(result.get(6));

            propList.add(jxsRepRateProp);

        }


        //表1经销商排名
        //全国
        List<JxsRepTotalInfo> sort =
                resultList.stream().filter(o -> o.getRangeType().equals(0)).sorted(Comparator.comparing(JxsRepTotalInfo::getEbt)).collect(Collectors.toList());
        Collections.reverse(sort);
        for (int i = 0; i < sort.size(); i++) {
            for (int j = 0; j < resultList.size(); j++) {
                if (resultList.get(j).getJxsDealerId() != null && resultList.get(j).getJxsDealerId().equals(sort.get(i).getJxsDealerId())) {
                    resultList.get(j).setEbtRank(BigDecimal.valueOf(i + 1));

                }
            }
        }
        //大区排名
        List<JxsRepTotalInfo> sortEast =
                resultList.stream().filter(o -> o.getRangeType().equals(0) && "东区".equals(o.getJxsRegionId())).sorted(Comparator.comparing(JxsRepTotalInfo::getEbt))
                        .collect(Collectors.toList());
        Collections.reverse(sortEast);
        for (int i = 0; i < sortEast.size(); i++) {
            for (int j = 0; j < resultList.size(); j++) {
                if (resultList.get(j).getJxsDealerId() != null && resultList.get(j).getJxsDealerId().equals(sortEast.get(i).getJxsDealerId())) {
                    resultList.get(j).setRegionEbtBank(BigDecimal.valueOf(i + 1));
                }
            }
        }

        List<JxsRepTotalInfo> sortSouth =
                resultList.stream().filter(o -> o.getRangeType().equals(0) && "南区".equals(o.getJxsRegionId())).sorted(Comparator.comparing(JxsRepTotalInfo::getEbt))
                        .collect(Collectors.toList());
        Collections.reverse(sortSouth);
        for (int i = 0; i < sortSouth.size(); i++) {
            for (int j = 0; j < resultList.size(); j++) {
                if (resultList.get(j).getJxsDealerId() != null && resultList.get(j).getJxsDealerId().equals(sortSouth.get(i).getJxsDealerId())) {
                    resultList.get(j).setRegionEbtBank(BigDecimal.valueOf(i + 1));
                }
            }
        }

        List<JxsRepTotalInfo> sortWest =
                resultList.stream().filter(o -> o.getRangeType().equals(0) && "西区".equals(o.getJxsRegionId())).sorted(Comparator.comparing(JxsRepTotalInfo::getEbt))
                        .collect(Collectors.toList());
        Collections.reverse(sortWest);
        for (int i = 0; i < sortWest.size(); i++) {
            for (int j = 0; j < resultList.size(); j++) {
                if (resultList.get(j).getJxsDealerId() != null && resultList.get(j).getJxsDealerId().equals(sortWest.get(i).getJxsDealerId())) {
                    resultList.get(j).setRegionEbtBank(BigDecimal.valueOf(i + 1));
                }
            }
        }

        List<JxsRepTotalInfo> sortNorth =
                resultList.stream().filter(o -> o.getRangeType().equals(0) && "北区".equals(o.getJxsRegionId())).sorted(Comparator.comparing(JxsRepTotalInfo::getEbt))
                        .collect(Collectors.toList());
        Collections.reverse(sortNorth);
        for (int i = 0; i < sortNorth.size(); i++) {
            for (int j = 0; j < resultList.size(); j++) {
                if (resultList.get(j).getJxsDealerId() != null && resultList.get(j).getJxsDealerId().equals(sortNorth.get(i).getJxsDealerId())) {
                    resultList.get(j).setRegionEbtBank(BigDecimal.valueOf(i + 1));
                }
            }
        }

//        List<JxsRepTotalInfo> sortCentre =
//                resultList.stream().filter(o -> o.getRangeType().equals(0) && "中区".equals(o.getJxsRegionId())).sorted(Comparator.comparing(JxsRepTotalInfo::getEbt))
//                        .collect(Collectors.toList());
//        Collections.reverse(sortCentre);
//        for (int i = 0; i < sortCentre.size(); i++) {
//            for (int j = 0; j < resultList.size(); j++) {
//                if (resultList.get(j).getJxsDealerId() != null && resultList.get(j).getJxsDealerId().equals(sortCentre.get(i).getJxsDealerId())) {
//                    resultList.get(j).setRegionEbtBank(BigDecimal.valueOf(i + 1));
//                }
//            }
//        }


        try {
            databaseDao.deleteJxsRepTotalInfo(yearId, quarterId);
            databaseDao.insertJxsRepTotalInfo(resultList);

        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }


        try {
            databaseDao.deleteJxsRepRateProp(yearId, quarterId);
            databaseDao.insertJxsRepRateProp(propList);

        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }


    }

    @Override
    public void handleJxsRepKpiTtl(String yearId, String quarterId, List<DealerForm> dealerList, List<DealerForm> regionDealerCount, Map<String, Object> carMap,
                                   Map<String, Object> usedMap, Map<String, Object> saleMap, Map<String, Object> globalMap) throws NoSuchAlgorithmException {

        List<JxsRepKpiTtl> resultList = new ArrayList<>();
        ObjectMapper objectMapper = new ObjectMapper();
        JxsRepKpiTtl jxsRepKpiTtl;

        //全国
        jxsRepKpiTtl = new JxsRepKpiTtl();
        jxsRepKpiTtl.setId(getSecureRandom());//ID
        jxsRepKpiTtl.setYearId(yearId);//年份
        jxsRepKpiTtl.setQuarterId(quarterId);//季度
        jxsRepKpiTtl.setRangeType(4);//rangeType
        jxsRepKpiTtl.setStatisType(1);//累计or当前
        jxsRepKpiTtl.setDealerNum(dealerList.size());
        jxsRepKpiTtl.setAsAbsorptivity(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get售后吸收率());
        jxsRepKpiTtl.setRateBeforeTax(objectMapper.convertValue(globalMap.get("总体_全国"), GlobalIndex.class).get税前净利润率());
        jxsRepKpiTtl.setComGrossMargin(objectMapper.convertValue(globalMap.get("总体_全国"), GlobalIndex.class).get综合毛利率());
        jxsRepKpiTtl.setExpenseRatio(objectMapper.convertValue(globalMap.get("总体_全国"), GlobalIndex.class).get费用率());
        jxsRepKpiTtl.setAvrevRateBeforeTax(objectMapper.convertValue(globalMap.get("总体_全国"), GlobalIndex.class).get税前净利润平均单店().divide(BigDecimal.valueOf(10000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepKpiTtl.setAvrevIncome(objectMapper.convertValue(globalMap.get("总体_全国"), GlobalIndex.class).get平均单店营业收入().divide(BigDecimal.valueOf(10000), 4, BigDecimal.ROUND_HALF_EVEN));

        resultList.add(jxsRepKpiTtl);

        //全国
        jxsRepKpiTtl = new JxsRepKpiTtl();
        jxsRepKpiTtl.setId(getSecureRandom());//ID
        jxsRepKpiTtl.setYearId(yearId);//年份
        jxsRepKpiTtl.setQuarterId(quarterId);//季度
        jxsRepKpiTtl.setRangeType(4);//rangeType
        jxsRepKpiTtl.setStatisType(0);//累计or当前
        jxsRepKpiTtl.setDealerNum(dealerList.size());
        jxsRepKpiTtl.setAsAbsorptivity(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get售后吸收率());
        jxsRepKpiTtl.setRateBeforeTax(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).get税前净利润率());
        jxsRepKpiTtl.setComGrossMargin(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).get综合毛利率());
        jxsRepKpiTtl.setExpenseRatio(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).get费用率());
        jxsRepKpiTtl.setAvrevRateBeforeTax(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).get税前净利润平均单店().divide(BigDecimal.valueOf(10000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepKpiTtl.setAvrevIncome(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).get平均单店营业收入().divide(BigDecimal.valueOf(10000), 4, BigDecimal.ROUND_HALF_EVEN));

        resultList.add(jxsRepKpiTtl);

        //大区
        ArrayList<AfterSaleIndex> afterSaleArea = (ArrayList<AfterSaleIndex>) saleMap.get("售后_区域");
        ArrayList<GlobalIndex> gloablArea = (ArrayList<GlobalIndex>) globalMap.get("总体_区域");
        for (int i = 0; i < afterSaleArea.size(); i++) {
            jxsRepKpiTtl = new JxsRepKpiTtl();
            jxsRepKpiTtl.setId(getSecureRandom());//ID
            jxsRepKpiTtl.setYearId(yearId);//年份
            jxsRepKpiTtl.setQuarterId(quarterId);//季度
            jxsRepKpiTtl.setRangeType(3);//rangeType
            jxsRepKpiTtl.setStatisType(1);//累计or当前
            jxsRepKpiTtl.setDealerNum(Integer.parseInt(regionDealerCount.get(i).getDealerCount()));
            jxsRepKpiTtl.setJxsRegionId(afterSaleArea.get(i).get区域ID());
            jxsRepKpiTtl.setAsAbsorptivity(afterSaleArea.get(i).get售后吸收率());
            jxsRepKpiTtl.setRateBeforeTax(gloablArea.get(i).get税前净利润率());
            jxsRepKpiTtl.setComGrossMargin(gloablArea.get(i).get综合毛利率());
            jxsRepKpiTtl.setExpenseRatio(gloablArea.get(i).get费用率());
            jxsRepKpiTtl.setAvrevRateBeforeTax(gloablArea.get(i).get税前净利润平均单店().divide(BigDecimal.valueOf(10000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepKpiTtl.setAvrevIncome(gloablArea.get(i).get平均单店营业收入().divide(BigDecimal.valueOf(10000), 4, BigDecimal.ROUND_HALF_EVEN));

            resultList.add(jxsRepKpiTtl);
        }

        //大区
        ArrayList<AfterSaleIndex> afterSaleAreaTotal = (ArrayList<AfterSaleIndex>) saleMap.get("售后_区域累计");
        ArrayList<GlobalIndex> gloablAreaTotal = (ArrayList<GlobalIndex>) globalMap.get("总体_区域累计");
        for (int i = 0; i < afterSaleAreaTotal.size(); i++) {
            jxsRepKpiTtl = new JxsRepKpiTtl();
            jxsRepKpiTtl.setId(getSecureRandom());//ID
            jxsRepKpiTtl.setYearId(yearId);//年份
            jxsRepKpiTtl.setQuarterId(quarterId);//季度
            jxsRepKpiTtl.setRangeType(3);//rangeType
            jxsRepKpiTtl.setStatisType(0);//累计or当前
            jxsRepKpiTtl.setDealerNum(Integer.parseInt(regionDealerCount.get(i).getDealerCount()));
            jxsRepKpiTtl.setJxsRegionId(afterSaleAreaTotal.get(i).get区域ID());
            jxsRepKpiTtl.setAsAbsorptivity(afterSaleAreaTotal.get(i).get售后吸收率());
            jxsRepKpiTtl.setRateBeforeTax(gloablAreaTotal.get(i).get税前净利润率());
            jxsRepKpiTtl.setComGrossMargin(gloablAreaTotal.get(i).get综合毛利率());
            jxsRepKpiTtl.setExpenseRatio(gloablAreaTotal.get(i).get费用率());
            jxsRepKpiTtl.setAvrevRateBeforeTax(gloablAreaTotal.get(i).get税前净利润平均单店().divide(BigDecimal.valueOf(10000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepKpiTtl.setAvrevIncome(gloablAreaTotal.get(i).get平均单店营业收入().divide(BigDecimal.valueOf(10000), 4, BigDecimal.ROUND_HALF_EVEN));

            resultList.add(jxsRepKpiTtl);
        }

        //经销商
        ArrayList<AfterSaleIndex> afterSaleDealer = (ArrayList<AfterSaleIndex>) saleMap.get("售后_经销商");
        ArrayList<GlobalIndex> gloablDealer = (ArrayList<GlobalIndex>) globalMap.get("总体_经销商");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepKpiTtl = new JxsRepKpiTtl();
            jxsRepKpiTtl.setId(getSecureRandom());//ID
            jxsRepKpiTtl.setYearId(yearId);//年份
            jxsRepKpiTtl.setQuarterId(quarterId);//季度
            jxsRepKpiTtl.setRangeType(0);//rangeType
            jxsRepKpiTtl.setDealerNum(1);//经销商数量
            jxsRepKpiTtl.setStatisType(1);//累计or当前
            jxsRepKpiTtl.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepKpiTtl.setAsAbsorptivity(afterSaleDealer.get(i).get售后吸收率());
            jxsRepKpiTtl.setRateBeforeTax(gloablDealer.get(i).get税前净利润率());
            jxsRepKpiTtl.setComGrossMargin(gloablDealer.get(i).get综合毛利率());
            jxsRepKpiTtl.setExpenseRatio(gloablDealer.get(i).get费用率());
            jxsRepKpiTtl.setAvrevRateBeforeTax(gloablDealer.get(i).get税前净利润平均单店().divide(BigDecimal.valueOf(10000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepKpiTtl.setAvrevIncome(gloablDealer.get(i).get平均单店营业收入().divide(BigDecimal.valueOf(10000), 4, BigDecimal.ROUND_HALF_EVEN));

            resultList.add(jxsRepKpiTtl);
        }

        //经销商
        ArrayList<AfterSaleIndex> afterSaleDealerTotal = (ArrayList<AfterSaleIndex>) saleMap.get("售后_经销商累计");
        ArrayList<GlobalIndex> gloablDealerTotal = (ArrayList<GlobalIndex>) globalMap.get("总体_经销商累计");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepKpiTtl = new JxsRepKpiTtl();
            jxsRepKpiTtl.setId(getSecureRandom());//ID
            jxsRepKpiTtl.setYearId(yearId);//年份
            jxsRepKpiTtl.setQuarterId(quarterId);//季度
            jxsRepKpiTtl.setRangeType(0);//rangeType
            jxsRepKpiTtl.setDealerNum(1);//经销商数量
            jxsRepKpiTtl.setStatisType(0);//累计or当前
            jxsRepKpiTtl.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepKpiTtl.setAsAbsorptivity(afterSaleDealerTotal.get(i).get售后吸收率());
            jxsRepKpiTtl.setRateBeforeTax(gloablDealerTotal.get(i).get税前净利润率());
            jxsRepKpiTtl.setComGrossMargin(gloablDealerTotal.get(i).get综合毛利率());
            jxsRepKpiTtl.setExpenseRatio(gloablDealerTotal.get(i).get费用率());
            jxsRepKpiTtl.setAvrevRateBeforeTax(gloablDealerTotal.get(i).get税前净利润平均单店().divide(BigDecimal.valueOf(10000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepKpiTtl.setAvrevIncome(gloablDealerTotal.get(i).get平均单店营业收入().divide(BigDecimal.valueOf(10000), 4, BigDecimal.ROUND_HALF_EVEN));

            resultList.add(jxsRepKpiTtl);
        }

        try {
            databaseDao.deleteJxsRepKpiTtl(yearId, quarterId);
            databaseDao.insertJxsRepKpiTtl(resultList);

        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }


    }

    @Override
    public void handleJxsRepKpiNcs(String yearId, String quarterId, List<DealerForm> dealerList, Map<String, Object> carMap, Map<String, Object> usedMap,
                                   Map<String, Object> saleMap, Map<String, Object> globalMap) {

        List<JxsRepKpiNcs> resultList = new ArrayList<>();
        ObjectMapper objectMapper = new ObjectMapper();
        JxsRepKpiNcs jxsRepKpiNcs;

        //全国
        jxsRepKpiNcs = new JxsRepKpiNcs();
        jxsRepKpiNcs.setId(getUUID());//ID
        jxsRepKpiNcs.setYearId(yearId);//年份
        jxsRepKpiNcs.setQuarterId(quarterId);//季度
        jxsRepKpiNcs.setRangeType(4);//rangeType
        jxsRepKpiNcs.setStatisType(1);//累计or当前
        jxsRepKpiNcs.setGpLvl1(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get新车毛利Ⅰ对新车利润贡献率());
        jxsRepKpiNcs.setGpLvl2(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get新车毛利Ⅱ对新车利润贡献率());
        jxsRepKpiNcs.setGpLvl3(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get三级毛利率());

        resultList.add(jxsRepKpiNcs);

        //全国
        jxsRepKpiNcs = new JxsRepKpiNcs();
        jxsRepKpiNcs.setId(getUUID());//ID
        jxsRepKpiNcs.setYearId(yearId);//年份
        jxsRepKpiNcs.setQuarterId(quarterId);//季度
        jxsRepKpiNcs.setRangeType(4);//rangeType
        jxsRepKpiNcs.setStatisType(0);//累计or当前
        jxsRepKpiNcs.setGpLvl1(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get新车毛利Ⅰ对新车利润贡献率());
        jxsRepKpiNcs.setGpLvl2(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get新车毛利Ⅱ对新车利润贡献率());
        jxsRepKpiNcs.setGpLvl3(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get三级毛利率());

        resultList.add(jxsRepKpiNcs);

        //大区
        ArrayList<NewCarIndex> carArea = (ArrayList<NewCarIndex>) carMap.get("新车_区域");
        for (int i = 0; i < carArea.size(); i++) {
            jxsRepKpiNcs = new JxsRepKpiNcs();
            jxsRepKpiNcs.setId(getUUID());//ID
            jxsRepKpiNcs.setYearId(yearId);//年份
            jxsRepKpiNcs.setQuarterId(quarterId);//季度
            jxsRepKpiNcs.setRangeType(3);//rangeType
            jxsRepKpiNcs.setStatisType(1);//累计or当前
            jxsRepKpiNcs.setJxsRegionId(carArea.get(i).get区域ID());
            jxsRepKpiNcs.setGpLvl1(carArea.get(i).get新车毛利Ⅰ对新车利润贡献率());
            jxsRepKpiNcs.setGpLvl2(carArea.get(i).get新车毛利Ⅱ对新车利润贡献率());
            jxsRepKpiNcs.setGpLvl3(carArea.get(i).get三级毛利率());

            resultList.add(jxsRepKpiNcs);
        }

        //大区
        ArrayList<NewCarIndex> carAreaTotal = (ArrayList<NewCarIndex>) carMap.get("新车_区域累计");
        for (int i = 0; i < carAreaTotal.size(); i++) {
            jxsRepKpiNcs = new JxsRepKpiNcs();
            jxsRepKpiNcs.setId(getUUID());//ID
            jxsRepKpiNcs.setYearId(yearId);//年份
            jxsRepKpiNcs.setQuarterId(quarterId);//季度
            jxsRepKpiNcs.setRangeType(3);//rangeType
            jxsRepKpiNcs.setStatisType(0);//累计or当前
            jxsRepKpiNcs.setJxsRegionId(carAreaTotal.get(i).get区域ID());
            jxsRepKpiNcs.setGpLvl1(carAreaTotal.get(i).get新车毛利Ⅰ对新车利润贡献率());
            jxsRepKpiNcs.setGpLvl2(carAreaTotal.get(i).get新车毛利Ⅱ对新车利润贡献率());
            jxsRepKpiNcs.setGpLvl3(carAreaTotal.get(i).get三级毛利率());

            resultList.add(jxsRepKpiNcs);
        }

        //经销商
        ArrayList<NewCarIndex> carDealer = (ArrayList<NewCarIndex>) carMap.get("新车_经销商");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepKpiNcs = new JxsRepKpiNcs();
            jxsRepKpiNcs.setId(getUUID());//ID
            jxsRepKpiNcs.setYearId(yearId);//年份
            jxsRepKpiNcs.setQuarterId(quarterId);//季度
            jxsRepKpiNcs.setRangeType(0);//rangeType
            jxsRepKpiNcs.setStatisType(1);//累计or当前
            jxsRepKpiNcs.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepKpiNcs.setGpLvl1(carDealer.get(i).get新车毛利Ⅰ对新车利润贡献率());
            jxsRepKpiNcs.setGpLvl2(carDealer.get(i).get新车毛利Ⅱ对新车利润贡献率());
            jxsRepKpiNcs.setGpLvl3(carDealer.get(i).get三级毛利率());

            resultList.add(jxsRepKpiNcs);
        }

        //经销商
        ArrayList<NewCarIndex> carDealerTotal = (ArrayList<NewCarIndex>) carMap.get("新车_经销商累计");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepKpiNcs = new JxsRepKpiNcs();
            jxsRepKpiNcs.setId(getUUID());//ID
            jxsRepKpiNcs.setYearId(yearId);//年份
            jxsRepKpiNcs.setQuarterId(quarterId);//季度
            jxsRepKpiNcs.setRangeType(0);//rangeType
            jxsRepKpiNcs.setStatisType(0);//累计or当前
            jxsRepKpiNcs.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepKpiNcs.setGpLvl1(carDealerTotal.get(i).get新车毛利Ⅰ对新车利润贡献率());
            jxsRepKpiNcs.setGpLvl2(carDealerTotal.get(i).get新车毛利Ⅱ对新车利润贡献率());
            jxsRepKpiNcs.setGpLvl3(carDealerTotal.get(i).get三级毛利率());

            resultList.add(jxsRepKpiNcs);
        }

        try {
            databaseDao.deleteJxsRepKpiNcs(yearId, quarterId);
            databaseDao.insertJxsRepKpiNcs(resultList);

        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }


    }

    @Override
    public void handleJxsRepKpiAs(String yearId, String quarterId, List<DealerForm> dealerList, Map<String, Object> carMap, Map<String, Object> usedMap,
                                  Map<String, Object> saleMap, Map<String, Object> globalMap) {

        List<JxsRepKpiAs> resultList = new ArrayList<>();
        ObjectMapper objectMapper = new ObjectMapper();
        JxsRepKpiAs jxsRepKpiAs;

        //全国
        jxsRepKpiAs = new JxsRepKpiAs();
        jxsRepKpiAs.setId(getUUID());//ID
        jxsRepKpiAs.setYearId(yearId);//年份
        jxsRepKpiAs.setQuarterId(quarterId);//季度
        jxsRepKpiAs.setRangeType(4);//rangeType
        jxsRepKpiAs.setStatisType(1);//累计or当前
        jxsRepKpiAs.setAsGrossMargin(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get售后一级毛利率());
        jxsRepKpiAs.setAvrevAsOutput(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get平均单店售后产值().divide(BigDecimal.valueOf(10000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepKpiAs.setAvrevEnterNum(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get售后进厂台次平均单店().intValue());

        resultList.add(jxsRepKpiAs);

        jxsRepKpiAs = new JxsRepKpiAs();
        jxsRepKpiAs.setId(getUUID());//ID
        jxsRepKpiAs.setYearId(yearId);//年份
        jxsRepKpiAs.setQuarterId(quarterId);//季度
        jxsRepKpiAs.setRangeType(4);//rangeType
        jxsRepKpiAs.setStatisType(0);//累计or当前
        jxsRepKpiAs.setAsGrossMargin(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get售后一级毛利率());
        jxsRepKpiAs.setAvrevAsOutput(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店售后产值().divide(BigDecimal.valueOf(10000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepKpiAs.setAvrevEnterNum(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get售后进厂台次平均单店().intValue());

        resultList.add(jxsRepKpiAs);

        //大区
        ArrayList<AfterSaleIndex> afterSaleArea = (ArrayList<AfterSaleIndex>) saleMap.get("售后_区域");
        for (int i = 0; i < afterSaleArea.size(); i++) {
            jxsRepKpiAs = new JxsRepKpiAs();
            jxsRepKpiAs.setId(getUUID());//ID
            jxsRepKpiAs.setYearId(yearId);//年份
            jxsRepKpiAs.setQuarterId(quarterId);//季度
            jxsRepKpiAs.setRangeType(3);//rangeType
            jxsRepKpiAs.setStatisType(1);//累计or当前
            jxsRepKpiAs.setJxsRegionId(afterSaleArea.get(i).get区域ID());
            jxsRepKpiAs.setAsGrossMargin(afterSaleArea.get(i).get售后一级毛利率());
            jxsRepKpiAs.setAvrevAsOutput(afterSaleArea.get(i).get平均单店售后产值().divide(BigDecimal.valueOf(10000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepKpiAs.setAvrevEnterNum(afterSaleArea.get(i).get售后进厂台次平均单店().intValue());

            resultList.add(jxsRepKpiAs);
        }

        ArrayList<AfterSaleIndex> afterSaleAreaTotal = (ArrayList<AfterSaleIndex>) saleMap.get("售后_区域累计");
        for (int i = 0; i < afterSaleAreaTotal.size(); i++) {
            jxsRepKpiAs = new JxsRepKpiAs();
            jxsRepKpiAs.setId(getUUID());//ID
            jxsRepKpiAs.setYearId(yearId);//年份
            jxsRepKpiAs.setQuarterId(quarterId);//季度
            jxsRepKpiAs.setRangeType(3);//rangeType
            jxsRepKpiAs.setStatisType(0);//累计or当前
            jxsRepKpiAs.setJxsRegionId(afterSaleAreaTotal.get(i).get区域ID());
            jxsRepKpiAs.setAsGrossMargin(afterSaleAreaTotal.get(i).get售后一级毛利率());
            jxsRepKpiAs.setAvrevAsOutput(afterSaleAreaTotal.get(i).get平均单店售后产值().divide(BigDecimal.valueOf(10000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepKpiAs.setAvrevEnterNum(afterSaleAreaTotal.get(i).get售后进厂台次平均单店().intValue());

            resultList.add(jxsRepKpiAs);
        }

        //经销商
        ArrayList<AfterSaleIndex> afterSaleDealer = (ArrayList<AfterSaleIndex>) saleMap.get("售后_经销商");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepKpiAs = new JxsRepKpiAs();
            jxsRepKpiAs.setId(getUUID());//ID
            jxsRepKpiAs.setYearId(yearId);//年份
            jxsRepKpiAs.setQuarterId(quarterId);//季度
            jxsRepKpiAs.setRangeType(0);//rangeType
            jxsRepKpiAs.setStatisType(1);//累计or当前
            jxsRepKpiAs.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepKpiAs.setAsGrossMargin(afterSaleDealer.get(i).get售后一级毛利率());
            jxsRepKpiAs.setAvrevAsOutput(afterSaleDealer.get(i).get平均单店售后产值().divide(BigDecimal.valueOf(10000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepKpiAs.setAvrevEnterNum(afterSaleDealer.get(i).get售后进厂台次平均单店().intValue());

            resultList.add(jxsRepKpiAs);
        }

        ArrayList<AfterSaleIndex> afterSaleDealerTotal = (ArrayList<AfterSaleIndex>) saleMap.get("售后_经销商累计");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepKpiAs = new JxsRepKpiAs();
            jxsRepKpiAs.setId(getUUID());//ID
            jxsRepKpiAs.setYearId(yearId);//年份
            jxsRepKpiAs.setQuarterId(quarterId);//季度
            jxsRepKpiAs.setRangeType(0);//rangeType
            jxsRepKpiAs.setStatisType(0);//累计or当前
            jxsRepKpiAs.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepKpiAs.setAsGrossMargin(afterSaleDealerTotal.get(i).get售后一级毛利率());
            jxsRepKpiAs.setAvrevAsOutput(afterSaleDealerTotal.get(i).get平均单店售后产值().divide(BigDecimal.valueOf(10000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepKpiAs.setAvrevEnterNum(afterSaleDealerTotal.get(i).get售后进厂台次平均单店().intValue());

            resultList.add(jxsRepKpiAs);
        }

        try {
            databaseDao.deleteJxsRepKpiAs(yearId, quarterId);
            databaseDao.insertJxsRepKpiAs(resultList);


        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }

    }

    @Override
    public void handleJxsRepProfitAnal(String yearId, String quarterId, List<DealerForm> dealerList, Map<String, Object> carMap,
                                       Map<String, Object> usedMap, Map<String, Object> saleMap, Map<String, Object> globalMap) {

        List<JxsRepProfitAnal> resultList = new ArrayList<>();
        ObjectMapper objectMapper = new ObjectMapper();
        JxsRepProfitAnal jxsRepProfitAnal;

        jxsRepProfitAnal = new JxsRepProfitAnal();
        jxsRepProfitAnal.setId(getUUID());//ID
        jxsRepProfitAnal.setYearId(yearId);//年份
        jxsRepProfitAnal.setQuarterId(quarterId);//季度
        jxsRepProfitAnal.setRangeType(4);//rangeType
        jxsRepProfitAnal.setNcsRateTax2(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get新车业务毛利贡献率());
        jxsRepProfitAnal.setNcsAvrevVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get平均单店新车毛利Ⅲ().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepProfitAnal.setAsRateTax2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get售后业务毛利贡献率());
        jxsRepProfitAnal.setAsAvrevVal(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店售后毛利Ⅲ().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepProfitAnal.setUcRateTax2(objectMapper.convertValue(usedMap.get("二手车_全国累计"), UsedIndex.class).get二手车业务毛利贡献率());
        jxsRepProfitAnal.setUcAvrevVal(objectMapper.convertValue(usedMap.get("二手车_全国累计"), UsedIndex.class).get二手车平均单店().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepProfitAnal.setObRateTax2(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).get其他业务毛利贡献率());
        jxsRepProfitAnal.setObAvrevVal(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).get其他业务平均单店().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepProfitAnal.setDcRateTax2(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).get折旧费用率());
        jxsRepProfitAnal.setDcAvrevVal(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).get折旧平均单店费用().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepProfitAnal.setLcRateTax2(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).get人工成本费用率含人工());
        jxsRepProfitAnal.setLcAvrevVal(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).get人工成本含人工单店费用().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepProfitAnal.setMcRateTax2(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).get广告费用率());
        jxsRepProfitAnal.setMcAvrevVal(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).get广告平均单点费用().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepProfitAnal.setFcRateTax2(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).get财务费用率());
        jxsRepProfitAnal.setFcAvrevVal(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).get财务平均单店费用().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepProfitAnal.setOeRateTax2(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).get其他费用率());
        jxsRepProfitAnal.setOeAvrevVal(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).get其他费用平均单店费用().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepProfitAnal.setRateTax2(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).get税前净利润率());
        jxsRepProfitAnal.setAvrevVal(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).get税前净利润平均单店().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));

        resultList.add(jxsRepProfitAnal);


        //大区
        ArrayList<AfterSaleIndex> afterSaleAreaTotal = (ArrayList<AfterSaleIndex>) saleMap.get("售后_区域累计");
        ArrayList<GlobalIndex> gloablAreaTotal = (ArrayList<GlobalIndex>) globalMap.get("总体_区域累计");
        ArrayList<NewCarIndex> carAreaTotal = (ArrayList<NewCarIndex>) carMap.get("新车_区域累计");
        ArrayList<UsedIndex> usedAreaTotal = (ArrayList<UsedIndex>) usedMap.get("二手车_区域累计");
        for (int i = 0; i < afterSaleAreaTotal.size(); i++) {
            jxsRepProfitAnal = new JxsRepProfitAnal();
            jxsRepProfitAnal.setId(getUUID());//ID
            jxsRepProfitAnal.setYearId(yearId);//年份
            jxsRepProfitAnal.setQuarterId(quarterId);//季度
            jxsRepProfitAnal.setRangeType(3);//rangeType
            jxsRepProfitAnal.setJxsRegionId(afterSaleAreaTotal.get(i).get区域ID());
            jxsRepProfitAnal.setNcsRateTax2(carAreaTotal.get(i).get新车业务毛利贡献率());
            jxsRepProfitAnal.setNcsAvrevVal(carAreaTotal.get(i).get平均单店新车毛利Ⅲ().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepProfitAnal.setAsRateTax2(afterSaleAreaTotal.get(i).get售后业务毛利贡献率());
            jxsRepProfitAnal.setAsAvrevVal(afterSaleAreaTotal.get(i).get平均单店售后毛利Ⅲ().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepProfitAnal.setUcRateTax2(usedAreaTotal.get(i).get二手车业务毛利贡献率());
            jxsRepProfitAnal.setUcAvrevVal(usedAreaTotal.get(i).get二手车平均单店().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepProfitAnal.setObRateTax2(gloablAreaTotal.get(i).get其他业务毛利贡献率());
            jxsRepProfitAnal.setObAvrevVal(gloablAreaTotal.get(i).get其他业务平均单店().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepProfitAnal.setDcRateTax2(gloablAreaTotal.get(i).get折旧费用率());
            jxsRepProfitAnal.setDcAvrevVal(gloablAreaTotal.get(i).get折旧平均单店费用().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepProfitAnal.setLcRateTax2(gloablAreaTotal.get(i).get人工成本费用率含人工());
            jxsRepProfitAnal.setLcAvrevVal(gloablAreaTotal.get(i).get人工成本含人工单店费用().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepProfitAnal.setMcRateTax2(gloablAreaTotal.get(i).get广告费用率());
            jxsRepProfitAnal.setMcAvrevVal(gloablAreaTotal.get(i).get广告平均单点费用().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepProfitAnal.setFcRateTax2(gloablAreaTotal.get(i).get财务费用率());
            jxsRepProfitAnal.setFcAvrevVal(gloablAreaTotal.get(i).get财务平均单店费用().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepProfitAnal.setOeRateTax2(gloablAreaTotal.get(i).get其他费用率());
            jxsRepProfitAnal.setOeAvrevVal(gloablAreaTotal.get(i).get其他费用平均单店费用().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepProfitAnal.setRateTax2(gloablAreaTotal.get(i).get税前净利润率());
            jxsRepProfitAnal.setAvrevVal(gloablAreaTotal.get(i).get税前净利润平均单店().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));

            resultList.add(jxsRepProfitAnal);
        }

        //经销商
        ArrayList<AfterSaleIndex> afterSaleDealerTotal = (ArrayList<AfterSaleIndex>) saleMap.get("售后_经销商累计");
        ArrayList<GlobalIndex> gloablDealerTotal = (ArrayList<GlobalIndex>) globalMap.get("总体_经销商累计");
        ArrayList<NewCarIndex> carDealerTotal = (ArrayList<NewCarIndex>) carMap.get("新车_经销商累计");
        ArrayList<UsedIndex> usedDealerTotal = (ArrayList<UsedIndex>) usedMap.get("二手车_经销商累计");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepProfitAnal = new JxsRepProfitAnal();
            jxsRepProfitAnal.setId(getUUID());//ID
            jxsRepProfitAnal.setYearId(yearId);//年份
            jxsRepProfitAnal.setQuarterId(quarterId);//季度
            jxsRepProfitAnal.setRangeType(0);//rangeType
            jxsRepProfitAnal.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepProfitAnal.setNcsRateTax2(carDealerTotal.get(i).get新车业务毛利贡献率());
            jxsRepProfitAnal.setNcsAvrevVal(carDealerTotal.get(i).get平均单店新车毛利Ⅲ().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepProfitAnal.setAsRateTax2(afterSaleDealerTotal.get(i).get售后业务毛利贡献率());
            jxsRepProfitAnal.setAsAvrevVal(afterSaleDealerTotal.get(i).get平均单店售后毛利Ⅲ().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepProfitAnal.setUcRateTax2(usedDealerTotal.get(i).get二手车业务毛利贡献率());
            jxsRepProfitAnal.setUcAvrevVal(usedDealerTotal.get(i).get二手车平均单店().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepProfitAnal.setObRateTax2(gloablDealerTotal.get(i).get其他业务毛利贡献率());
            jxsRepProfitAnal.setObAvrevVal(gloablDealerTotal.get(i).get其他业务平均单店().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepProfitAnal.setDcRateTax2(gloablDealerTotal.get(i).get折旧费用率());
            jxsRepProfitAnal.setDcAvrevVal(gloablDealerTotal.get(i).get折旧平均单店费用().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepProfitAnal.setLcRateTax2(gloablDealerTotal.get(i).get人工成本费用率含人工());
            jxsRepProfitAnal.setLcAvrevVal(gloablDealerTotal.get(i).get人工成本含人工单店费用().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepProfitAnal.setMcRateTax2(gloablDealerTotal.get(i).get广告费用率());
            jxsRepProfitAnal.setMcAvrevVal(gloablDealerTotal.get(i).get广告平均单点费用().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepProfitAnal.setFcRateTax2(gloablDealerTotal.get(i).get财务费用率());
            jxsRepProfitAnal.setFcAvrevVal(gloablDealerTotal.get(i).get财务平均单店费用().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepProfitAnal.setOeRateTax2(gloablDealerTotal.get(i).get其他费用率());
            jxsRepProfitAnal.setOeAvrevVal(gloablDealerTotal.get(i).get其他费用平均单店费用().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepProfitAnal.setRateTax2(gloablDealerTotal.get(i).get税前净利润率());
            jxsRepProfitAnal.setAvrevVal(gloablDealerTotal.get(i).get税前净利润平均单店().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));

            resultList.add(jxsRepProfitAnal);
        }


        try {
            databaseDao.deleteJxsRepProfitAnal(yearId, quarterId);
            databaseDao.insertJxsRepProfitAnal(resultList);

        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }


    }

    @Override
    public void handleJxsRepNcsGrossProfit(String yearId, String quarterId, List<DealerForm> dealerList, Map<String, Object> carMap,
                                           Map<String, Object> usedMap, Map<String, Object> saleMap, Map<String, Object> globalMap) {
        List<JxsRepNcsGrossProfit> resultList = new ArrayList<>();
        ObjectMapper objectMapper = new ObjectMapper();
        JxsRepNcsGrossProfit jxsRepNcsGrossProfit;

        //全国
        jxsRepNcsGrossProfit = new JxsRepNcsGrossProfit();
        jxsRepNcsGrossProfit.setId(getUUID());//ID
        jxsRepNcsGrossProfit.setYearId(yearId);//年份
        jxsRepNcsGrossProfit.setQuarterId(quarterId);//季度
        jxsRepNcsGrossProfit.setRangeType(4);//rangeType
        jxsRepNcsGrossProfit.setGml1RateTax2(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get新车一级毛利率());
        jxsRepNcsGrossProfit.setGml1AvrevVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get平均单店新车毛利Ⅰ().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepNcsGrossProfit.setRebateRateTax2(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get新车返利对新车利润贡献率());
        jxsRepNcsGrossProfit.setRebateAvrevVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get平均单店新车返利().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepNcsGrossProfit.setGml2RateTax2(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get新车二级毛利率());
        jxsRepNcsGrossProfit.setGml2AvrevVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get平均单店新车毛利Ⅱ().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepNcsGrossProfit.setRpRateTax2(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get精品备件衍生贡献());
        jxsRepNcsGrossProfit.setRpAvrevVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get平均单店精品备件衍生().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepNcsGrossProfit.setFinRateTax2(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get金融衍生贡献());
        jxsRepNcsGrossProfit.setFinAvrevVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get平均单店金融衍生().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepNcsGrossProfit.setInsRateTax2(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get保险衍生贡献());
        jxsRepNcsGrossProfit.setInsAvrevVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get平均单店保险衍生().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepNcsGrossProfit.setOdRateTax2(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get其他衍生贡献());
        jxsRepNcsGrossProfit.setOdAvrevVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get平均单店其他衍生().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepNcsGrossProfit.setGml3RateTax2(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get三级毛利率());
        jxsRepNcsGrossProfit.setGml3AvrevVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get平均单店新车毛利Ⅲ().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepNcsGrossProfit.setLcRateTax2(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get新车业务人工成本费用贡献());
        jxsRepNcsGrossProfit.setLcAvrevVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get平均单店人工成本不含工时().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepNcsGrossProfit.setMcRateTax2(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get新车业务市场费用贡献());
        jxsRepNcsGrossProfit.setMcAvrevVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get平均单店市场费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepNcsGrossProfit.setFcRateTax2(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get新车业务财务费用贡献());
        jxsRepNcsGrossProfit.setFcAvrevVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get平均单店财务费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepNcsGrossProfit.setOeRateTax2(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get新车业务其他费用贡献());
        jxsRepNcsGrossProfit.setOeAvrevVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get平均单店其他业务费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepNcsGrossProfit.setPcRateTax2(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get新车利润贡献());
        jxsRepNcsGrossProfit.setPcAvrevVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get平均单店新车利润().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));

        resultList.add(jxsRepNcsGrossProfit);

        //大区
        ArrayList<NewCarIndex> carAreaTotal = (ArrayList<NewCarIndex>) carMap.get("新车_区域累计");
        for (int i = 0; i < carAreaTotal.size(); i++) {
            jxsRepNcsGrossProfit = new JxsRepNcsGrossProfit();
            jxsRepNcsGrossProfit.setId(getUUID());//ID
            jxsRepNcsGrossProfit.setYearId(yearId);//年份
            jxsRepNcsGrossProfit.setQuarterId(quarterId);//季度
            jxsRepNcsGrossProfit.setRangeType(3);//rangeType
            jxsRepNcsGrossProfit.setJxsRegionId(carAreaTotal.get(i).get区域ID());
            jxsRepNcsGrossProfit.setGml1RateTax2(carAreaTotal.get(i).get新车一级毛利率());
            jxsRepNcsGrossProfit.setGml1AvrevVal(carAreaTotal.get(i).get平均单店新车毛利Ⅰ().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossProfit.setRebateRateTax2(carAreaTotal.get(i).get新车返利对新车利润贡献率());
            jxsRepNcsGrossProfit.setRebateAvrevVal(carAreaTotal.get(i).get平均单店新车返利().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossProfit.setGml2RateTax2(carAreaTotal.get(i).get新车二级毛利率());
            jxsRepNcsGrossProfit.setGml2AvrevVal(carAreaTotal.get(i).get平均单店新车毛利Ⅱ().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossProfit.setRpRateTax2(carAreaTotal.get(i).get精品备件衍生贡献());
            jxsRepNcsGrossProfit.setRpAvrevVal(carAreaTotal.get(i).get平均单店精品备件衍生().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossProfit.setFinRateTax2(carAreaTotal.get(i).get金融衍生贡献());
            jxsRepNcsGrossProfit.setFinAvrevVal(carAreaTotal.get(i).get平均单店金融衍生().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossProfit.setInsRateTax2(carAreaTotal.get(i).get保险衍生贡献());
            jxsRepNcsGrossProfit.setInsAvrevVal(carAreaTotal.get(i).get平均单店保险衍生().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossProfit.setOdRateTax2(carAreaTotal.get(i).get其他衍生贡献());
            jxsRepNcsGrossProfit.setOdAvrevVal(carAreaTotal.get(i).get平均单店其他衍生().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossProfit.setGml3RateTax2(carAreaTotal.get(i).get三级毛利率());
            jxsRepNcsGrossProfit.setGml3AvrevVal(carAreaTotal.get(i).get平均单店新车毛利Ⅲ().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossProfit.setLcRateTax2(carAreaTotal.get(i).get新车业务人工成本费用贡献());
            jxsRepNcsGrossProfit.setLcAvrevVal(carAreaTotal.get(i).get平均单店人工成本不含工时().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossProfit.setMcRateTax2(carAreaTotal.get(i).get新车业务市场费用贡献());
            jxsRepNcsGrossProfit.setMcAvrevVal(carAreaTotal.get(i).get平均单店市场费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossProfit.setFcRateTax2(carAreaTotal.get(i).get新车业务财务费用贡献());
            jxsRepNcsGrossProfit.setFcAvrevVal(carAreaTotal.get(i).get平均单店财务费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossProfit.setOeRateTax2(carAreaTotal.get(i).get新车业务其他费用贡献());
            jxsRepNcsGrossProfit.setOeAvrevVal(carAreaTotal.get(i).get平均单店其他业务费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossProfit.setPcRateTax2(carAreaTotal.get(i).get新车利润贡献());
            jxsRepNcsGrossProfit.setPcAvrevVal(carAreaTotal.get(i).get平均单店新车利润().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));

            resultList.add(jxsRepNcsGrossProfit);
        }

        //经销商
        ArrayList<NewCarIndex> carDealerTotal = (ArrayList<NewCarIndex>) carMap.get("新车_经销商累计");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepNcsGrossProfit = new JxsRepNcsGrossProfit();
            jxsRepNcsGrossProfit.setId(getUUID());//ID
            jxsRepNcsGrossProfit.setYearId(yearId);//年份
            jxsRepNcsGrossProfit.setQuarterId(quarterId);//季度
            jxsRepNcsGrossProfit.setRangeType(0);//rangeType
            jxsRepNcsGrossProfit.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepNcsGrossProfit.setGml1RateTax2(carDealerTotal.get(i).get新车一级毛利率());
            jxsRepNcsGrossProfit.setGml1AvrevVal(carDealerTotal.get(i).get平均单店新车毛利Ⅰ().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossProfit.setRebateRateTax2(carDealerTotal.get(i).get新车返利对新车利润贡献率());
            jxsRepNcsGrossProfit.setRebateAvrevVal(carDealerTotal.get(i).get平均单店新车返利().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossProfit.setGml2RateTax2(carDealerTotal.get(i).get新车二级毛利率());
            jxsRepNcsGrossProfit.setGml2AvrevVal(carDealerTotal.get(i).get平均单店新车毛利Ⅱ().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossProfit.setRpRateTax2(carDealerTotal.get(i).get精品备件衍生贡献());
            jxsRepNcsGrossProfit.setRpAvrevVal(carDealerTotal.get(i).get平均单店精品备件衍生().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossProfit.setFinRateTax2(carDealerTotal.get(i).get金融衍生贡献());
            jxsRepNcsGrossProfit.setFinAvrevVal(carDealerTotal.get(i).get平均单店金融衍生().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossProfit.setInsRateTax2(carDealerTotal.get(i).get保险衍生贡献());
            jxsRepNcsGrossProfit.setInsAvrevVal(carDealerTotal.get(i).get平均单店保险衍生().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossProfit.setOdRateTax2(carDealerTotal.get(i).get其他衍生贡献());
            jxsRepNcsGrossProfit.setOdAvrevVal(carDealerTotal.get(i).get平均单店其他衍生().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossProfit.setGml3RateTax2(carDealerTotal.get(i).get三级毛利率());
            jxsRepNcsGrossProfit.setGml3AvrevVal(carDealerTotal.get(i).get平均单店新车毛利Ⅲ().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossProfit.setLcRateTax2(carDealerTotal.get(i).get新车业务人工成本费用贡献());
            jxsRepNcsGrossProfit.setLcAvrevVal(carDealerTotal.get(i).get平均单店人工成本不含工时().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossProfit.setMcRateTax2(carDealerTotal.get(i).get新车业务市场费用贡献());
            jxsRepNcsGrossProfit.setMcAvrevVal(carDealerTotal.get(i).get平均单店市场费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossProfit.setFcRateTax2(carDealerTotal.get(i).get新车业务财务费用贡献());
            jxsRepNcsGrossProfit.setFcAvrevVal(carDealerTotal.get(i).get平均单店财务费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossProfit.setOeRateTax2(carDealerTotal.get(i).get新车业务其他费用贡献());
            jxsRepNcsGrossProfit.setOeAvrevVal(carDealerTotal.get(i).get平均单店其他业务费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossProfit.setPcRateTax2(carDealerTotal.get(i).get新车利润贡献());
            jxsRepNcsGrossProfit.setPcAvrevVal(carDealerTotal.get(i).get平均单店新车利润().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));

            resultList.add(jxsRepNcsGrossProfit);
        }

        try {
            databaseDao.deleteJxsRepNcsGrossProfit(yearId, quarterId);
            databaseDao.insertJxsRepNcsGrossProfit(resultList);


        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }


    }

    @Override
    public void handleJxsRepAsGrossProfit(String yearId, String quarterId, List<DealerForm> dealerList, Map<String, Object> carMap,
                                          Map<String, Object> usedMap, Map<String, Object> saleMap, Map<String, Object> globalMap) {

        List<JxsRepAsGrossProfit> resultList = new ArrayList<>();
        ObjectMapper objectMapper = new ObjectMapper();
        JxsRepAsGrossProfit jxsRepAsGrossProfit;

        //全国
        jxsRepAsGrossProfit = new JxsRepAsGrossProfit();
        jxsRepAsGrossProfit.setId(getUUID());//ID
        jxsRepAsGrossProfit.setYearId(yearId);//年份
        jxsRepAsGrossProfit.setQuarterId(quarterId);//季度
        jxsRepAsGrossProfit.setRangeType(4);//rangeType
        jxsRepAsGrossProfit.setGml1RateTax2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get售后毛利Ⅰ());
        jxsRepAsGrossProfit.setGml1AvrevVal(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店售后毛利Ⅰ().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAsGrossProfit.setRebateRateTax2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get备件返利贡献());
        jxsRepAsGrossProfit.setRebateAvrevVal(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店售后返利().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAsGrossProfit.setGml2RateTax2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get售后毛利Ⅱ());
        jxsRepAsGrossProfit.setGml2AvrevVal(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店售后毛利Ⅱ().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAsGrossProfit.setRpRateTax2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get售后精品备件衍生贡献());
        jxsRepAsGrossProfit.setRpAvrevVal(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店售后精品备件衍生().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAsGrossProfit.setInsRateTax2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get售后保险衍生贡献());
        jxsRepAsGrossProfit.setInsAvrevVal(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店售后保险衍生().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAsGrossProfit.setGml3RateTax2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get售后三级毛利率());
        jxsRepAsGrossProfit.setGml3AvrevVal(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店售后毛利Ⅲ().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAsGrossProfit.setLcRateTax2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get售后业务人工成本对售后利润贡献率());
        jxsRepAsGrossProfit.setLcAvrevVal(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店售后人工成本含工时().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAsGrossProfit.setMcRateTax2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get售后业务市场费用对售后利润贡献率());
        jxsRepAsGrossProfit.setMcAvrevVal(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店市场费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAsGrossProfit.setFcRateTax2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get售后业务财务费用对售后利润贡献率());
        jxsRepAsGrossProfit.setFcAvrevVal(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店财务费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAsGrossProfit.setOeRateTax2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get售后业务业务其他费用贡献());
        jxsRepAsGrossProfit.setOeAvrevVal(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店其他费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAsGrossProfit.setPcRateTax2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get售后利润贡献());
        jxsRepAsGrossProfit.setPcAvrevVal(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店售后利润().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));

        resultList.add(jxsRepAsGrossProfit);

        //大区
        ArrayList<AfterSaleIndex> afterSaleAreaTotal = (ArrayList<AfterSaleIndex>) saleMap.get("售后_区域累计");
        for (int i = 0; i < afterSaleAreaTotal.size(); i++) {
            jxsRepAsGrossProfit = new JxsRepAsGrossProfit();
            jxsRepAsGrossProfit.setId(getUUID());//ID
            jxsRepAsGrossProfit.setYearId(yearId);//年份
            jxsRepAsGrossProfit.setQuarterId(quarterId);//季度
            jxsRepAsGrossProfit.setRangeType(3);//rangeType
            jxsRepAsGrossProfit.setJxsRegionId(afterSaleAreaTotal.get(i).get区域ID());
            jxsRepAsGrossProfit.setGml1RateTax2(afterSaleAreaTotal.get(i).get售后毛利Ⅰ());
            jxsRepAsGrossProfit.setGml1AvrevVal(afterSaleAreaTotal.get(i).get平均单店售后毛利Ⅰ().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsGrossProfit.setRebateRateTax2(afterSaleAreaTotal.get(i).get备件返利贡献());
            jxsRepAsGrossProfit.setRebateAvrevVal(afterSaleAreaTotal.get(i).get平均单店售后返利().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsGrossProfit.setGml2RateTax2(afterSaleAreaTotal.get(i).get售后毛利Ⅱ());
            jxsRepAsGrossProfit.setGml2AvrevVal(afterSaleAreaTotal.get(i).get平均单店售后毛利Ⅱ().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsGrossProfit.setRpRateTax2(afterSaleAreaTotal.get(i).get售后精品备件衍生贡献());
            jxsRepAsGrossProfit.setRpAvrevVal(afterSaleAreaTotal.get(i).get平均单店售后精品备件衍生().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsGrossProfit.setInsRateTax2(afterSaleAreaTotal.get(i).get售后保险衍生贡献());
            jxsRepAsGrossProfit.setInsAvrevVal(afterSaleAreaTotal.get(i).get平均单店售后保险衍生().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsGrossProfit.setGml3RateTax2(afterSaleAreaTotal.get(i).get售后三级毛利率());
            jxsRepAsGrossProfit.setGml3AvrevVal(afterSaleAreaTotal.get(i).get平均单店售后毛利Ⅲ().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsGrossProfit.setLcRateTax2(afterSaleAreaTotal.get(i).get售后业务人工成本对售后利润贡献率());
            jxsRepAsGrossProfit.setLcAvrevVal(afterSaleAreaTotal.get(i).get平均单店售后人工成本含工时().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsGrossProfit.setMcRateTax2(afterSaleAreaTotal.get(i).get售后业务市场费用对售后利润贡献率());
            jxsRepAsGrossProfit.setMcAvrevVal(afterSaleAreaTotal.get(i).get平均单店市场费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsGrossProfit.setFcRateTax2(afterSaleAreaTotal.get(i).get售后业务财务费用对售后利润贡献率());
            jxsRepAsGrossProfit.setFcAvrevVal(afterSaleAreaTotal.get(i).get平均单店财务费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsGrossProfit.setOeRateTax2(afterSaleAreaTotal.get(i).get售后业务业务其他费用贡献());
            jxsRepAsGrossProfit.setOeAvrevVal(afterSaleAreaTotal.get(i).get平均单店其他费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsGrossProfit.setPcRateTax2(afterSaleAreaTotal.get(i).get售后利润贡献());
            jxsRepAsGrossProfit.setPcAvrevVal(afterSaleAreaTotal.get(i).get平均单店售后利润().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));

            resultList.add(jxsRepAsGrossProfit);
        }

        //经销商
        ArrayList<AfterSaleIndex> afterSaleDealerTotal = (ArrayList<AfterSaleIndex>) saleMap.get("售后_经销商累计");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepAsGrossProfit = new JxsRepAsGrossProfit();
            jxsRepAsGrossProfit.setId(getUUID());//ID
            jxsRepAsGrossProfit.setYearId(yearId);//年份
            jxsRepAsGrossProfit.setQuarterId(quarterId);//季度
            jxsRepAsGrossProfit.setRangeType(0);//rangeType
            jxsRepAsGrossProfit.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepAsGrossProfit.setGml1RateTax2(afterSaleDealerTotal.get(i).get售后毛利Ⅰ());
            jxsRepAsGrossProfit.setGml1AvrevVal(afterSaleDealerTotal.get(i).get平均单店售后毛利Ⅰ().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsGrossProfit.setRebateRateTax2(afterSaleDealerTotal.get(i).get备件返利贡献());
            jxsRepAsGrossProfit.setRebateAvrevVal(afterSaleDealerTotal.get(i).get平均单店售后返利().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsGrossProfit.setGml2RateTax2(afterSaleDealerTotal.get(i).get售后毛利Ⅱ());
            jxsRepAsGrossProfit.setGml2AvrevVal(afterSaleDealerTotal.get(i).get平均单店售后毛利Ⅱ().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsGrossProfit.setRpRateTax2(afterSaleDealerTotal.get(i).get售后精品备件衍生贡献());
            jxsRepAsGrossProfit.setRpAvrevVal(afterSaleDealerTotal.get(i).get平均单店售后精品备件衍生().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsGrossProfit.setInsRateTax2(afterSaleDealerTotal.get(i).get售后保险衍生贡献());
            jxsRepAsGrossProfit.setInsAvrevVal(afterSaleDealerTotal.get(i).get平均单店售后保险衍生().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsGrossProfit.setGml3RateTax2(afterSaleDealerTotal.get(i).get售后三级毛利率());
            jxsRepAsGrossProfit.setGml3AvrevVal(afterSaleDealerTotal.get(i).get平均单店售后毛利Ⅲ().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsGrossProfit.setLcRateTax2(afterSaleDealerTotal.get(i).get售后业务人工成本对售后利润贡献率());
            jxsRepAsGrossProfit.setLcAvrevVal(afterSaleDealerTotal.get(i).get平均单店售后人工成本含工时().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsGrossProfit.setMcRateTax2(afterSaleDealerTotal.get(i).get售后业务市场费用对售后利润贡献率());
            jxsRepAsGrossProfit.setMcAvrevVal(afterSaleDealerTotal.get(i).get平均单店市场费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsGrossProfit.setFcRateTax2(afterSaleDealerTotal.get(i).get售后业务财务费用对售后利润贡献率());
            jxsRepAsGrossProfit.setFcAvrevVal(afterSaleDealerTotal.get(i).get平均单店财务费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsGrossProfit.setOeRateTax2(afterSaleDealerTotal.get(i).get售后业务业务其他费用贡献());
            jxsRepAsGrossProfit.setOeAvrevVal(afterSaleDealerTotal.get(i).get平均单店其他费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsGrossProfit.setPcRateTax2(afterSaleDealerTotal.get(i).get售后利润贡献());
            jxsRepAsGrossProfit.setPcAvrevVal(afterSaleDealerTotal.get(i).get平均单店售后利润().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));

            resultList.add(jxsRepAsGrossProfit);
        }

        try {
            databaseDao.deleteJxsRepAsGrossProfit(yearId, quarterId);
            databaseDao.insertJxsRepAsGrossProfit(resultList);

        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }


    }

    @Override
    public void handleJxsRepAvrevCostRatio(String yearId, String quarterId, List<DealerForm> dealerList, Map<String, Object> carMap,
                                           Map<String, Object> usedMap, Map<String, Object> saleMap, Map<String, Object> globalMap) {

        List<JxsRepAvrevCostRatio> resultList = new ArrayList<>();
        ObjectMapper objectMapper = new ObjectMapper();
        JxsRepAvrevCostRatio jxsRepAvrevCostRatio;

        //全国
        jxsRepAvrevCostRatio = new JxsRepAvrevCostRatio();
        jxsRepAvrevCostRatio.setId(getUUID());//ID
        jxsRepAvrevCostRatio.setYearId(yearId);//年份
        jxsRepAvrevCostRatio.setQuarterId(quarterId);//季度
        jxsRepAvrevCostRatio.setRangeType(4);//rangeType
        jxsRepAvrevCostRatio.setTtlCostRatio(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).get费用总计费用率());
        jxsRepAvrevCostRatio.setTtlCostVal(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).get费用总计平均单店费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAvrevCostRatio.setLcCostRatio(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).get人工成本费用率());
        jxsRepAvrevCostRatio.setLcCostVal(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).get人工成本平均单店费用不含人工().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAvrevCostRatio.setDepCostRatio(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).get折旧费用率());
        jxsRepAvrevCostRatio.setDepCostVal(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).get折旧平均单店费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAvrevCostRatio.setAdvCostRatio(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).get广告费用率());
        jxsRepAvrevCostRatio.setAdvCostVal(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).get广告平均单点费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAvrevCostRatio.setFinCostRatio(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).get财务费用率());
        jxsRepAvrevCostRatio.setFinCostVal(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).get财务平均单店费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAvrevCostRatio.setOtCostRatio(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).get其他费用率());
        jxsRepAvrevCostRatio.setOtCostVal(objectMapper.convertValue(globalMap.get("总体_全国累计"), GlobalIndex.class).get其他费用平均单店费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));

        resultList.add(jxsRepAvrevCostRatio);

        //大区
        ArrayList<GlobalIndex> globalArea = (ArrayList<GlobalIndex>) globalMap.get("总体_区域累计");
        for (int i = 0; i < globalArea.size(); i++) {
            jxsRepAvrevCostRatio = new JxsRepAvrevCostRatio();
            jxsRepAvrevCostRatio.setId(getUUID());//ID
            jxsRepAvrevCostRatio.setYearId(yearId);//年份
            jxsRepAvrevCostRatio.setQuarterId(quarterId);//季度
            jxsRepAvrevCostRatio.setRangeType(3);//rangeType
            jxsRepAvrevCostRatio.setJxsRegionId(globalArea.get(i).get区域ID());
            jxsRepAvrevCostRatio.setTtlCostRatio(globalArea.get(i).get费用总计费用率());
            jxsRepAvrevCostRatio.setTtlCostVal(globalArea.get(i).get费用总计平均单店费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAvrevCostRatio.setLcCostRatio(globalArea.get(i).get人工成本费用率());
            jxsRepAvrevCostRatio.setLcCostVal(globalArea.get(i).get人工成本平均单店费用不含人工().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAvrevCostRatio.setDepCostRatio(globalArea.get(i).get折旧费用率());
            jxsRepAvrevCostRatio.setDepCostVal(globalArea.get(i).get折旧平均单店费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAvrevCostRatio.setAdvCostRatio(globalArea.get(i).get广告费用率());
            jxsRepAvrevCostRatio.setAdvCostVal(globalArea.get(i).get广告平均单点费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAvrevCostRatio.setFinCostRatio(globalArea.get(i).get财务费用率());
            jxsRepAvrevCostRatio.setFinCostVal(globalArea.get(i).get财务平均单店费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAvrevCostRatio.setOtCostRatio(globalArea.get(i).get其他费用率());
            jxsRepAvrevCostRatio.setOtCostVal(globalArea.get(i).get其他费用平均单店费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));


            resultList.add(jxsRepAvrevCostRatio);
        }

        //经销商
        ArrayList<GlobalIndex> globalDealer = (ArrayList<GlobalIndex>) globalMap.get("总体_经销商累计");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepAvrevCostRatio = new JxsRepAvrevCostRatio();
            jxsRepAvrevCostRatio.setId(getUUID());//ID
            jxsRepAvrevCostRatio.setYearId(yearId);//年份
            jxsRepAvrevCostRatio.setQuarterId(quarterId);//季度
            jxsRepAvrevCostRatio.setRangeType(0);//rangeType
            jxsRepAvrevCostRatio.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepAvrevCostRatio.setTtlCostRatio(globalDealer.get(i).get费用总计费用率());
            jxsRepAvrevCostRatio.setTtlCostVal(globalDealer.get(i).get费用总计平均单店费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAvrevCostRatio.setLcCostRatio(globalDealer.get(i).get人工成本费用率());
            jxsRepAvrevCostRatio.setLcCostVal(globalDealer.get(i).get人工成本平均单店费用不含人工().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAvrevCostRatio.setDepCostRatio(globalDealer.get(i).get折旧费用率());
            jxsRepAvrevCostRatio.setDepCostVal(globalDealer.get(i).get折旧平均单店费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAvrevCostRatio.setAdvCostRatio(globalDealer.get(i).get广告费用率());
            jxsRepAvrevCostRatio.setAdvCostVal(globalDealer.get(i).get广告平均单点费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAvrevCostRatio.setFinCostRatio(globalDealer.get(i).get财务费用率());
            jxsRepAvrevCostRatio.setFinCostVal(globalDealer.get(i).get财务平均单店费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAvrevCostRatio.setOtCostRatio(globalDealer.get(i).get其他费用率());
            jxsRepAvrevCostRatio.setOtCostVal(globalDealer.get(i).get其他费用平均单店费用().divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_EVEN));

            resultList.add(jxsRepAvrevCostRatio);
        }

        try {
            databaseDao.deleteJxsRepAvrevCostRatio(yearId, quarterId);
            databaseDao.insertJxsRepAvrevCostRatio(resultList);

        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }


    }

    @Override
    public void handleJxsRepAvrcarCost(String yearId, String quarterId, List<DealerForm> dealerList, Map<String, Object> carMap,
                                       Map<String, Object> usedMap, Map<String, Object> saleMap, Map<String, Object> globalMap) {

        List<JxsRepAvrcarCost> resultList = new ArrayList<>();
        ObjectMapper objectMapper = new ObjectMapper();
        JxsRepAvrcarCost jxsRepAvrcarCost;

        //全国
        jxsRepAvrcarCost = new JxsRepAvrcarCost();
        jxsRepAvrcarCost.setId(getUUID());//ID
        jxsRepAvrcarCost.setYearId(yearId);//年份
        jxsRepAvrcarCost.setQuarterId(quarterId);//季度
        jxsRepAvrcarCost.setRangeType(4);//rangeType
        jxsRepAvrcarCost.setTtlCostVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get费用合计平均单店费用().setScale(2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAvrcarCost.setLcCostVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get人工成本平均单车费用().setScale(2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAvrcarCost.setAdvCostVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get广告平均单车费用().setScale(2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAvrcarCost.setFinCostVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get财务平均单车费用().setScale(2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAvrcarCost.setOtCostVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get其他平均单车费用().setScale(2, BigDecimal.ROUND_HALF_EVEN));

        resultList.add(jxsRepAvrcarCost);

        //大区
        ArrayList<NewCarIndex> carAreaTotal = (ArrayList<NewCarIndex>) carMap.get("新车_区域累计");
        for (int i = 0; i < carAreaTotal.size(); i++) {
            jxsRepAvrcarCost = new JxsRepAvrcarCost();
            jxsRepAvrcarCost.setId(getUUID());//ID
            jxsRepAvrcarCost.setYearId(yearId);//年份
            jxsRepAvrcarCost.setQuarterId(quarterId);//季度
            jxsRepAvrcarCost.setRangeType(3);//rangeType
            jxsRepAvrcarCost.setJxsRegionId(carAreaTotal.get(i).get区域ID());
            jxsRepAvrcarCost.setTtlCostVal(carAreaTotal.get(i).get费用合计平均单店费用().setScale(2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAvrcarCost.setLcCostVal(carAreaTotal.get(i).get人工成本平均单车费用().setScale(2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAvrcarCost.setAdvCostVal(carAreaTotal.get(i).get广告平均单车费用().setScale(2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAvrcarCost.setFinCostVal(carAreaTotal.get(i).get财务平均单车费用().setScale(2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAvrcarCost.setOtCostVal(carAreaTotal.get(i).get其他平均单车费用().setScale(2, BigDecimal.ROUND_HALF_EVEN));

            resultList.add(jxsRepAvrcarCost);
        }

        //经销商
        ArrayList<NewCarIndex> carDealerTotal = (ArrayList<NewCarIndex>) carMap.get("新车_经销商累计");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepAvrcarCost = new JxsRepAvrcarCost();
            jxsRepAvrcarCost.setId(getUUID());//ID
            jxsRepAvrcarCost.setYearId(yearId);//年份
            jxsRepAvrcarCost.setQuarterId(quarterId);//季度
            jxsRepAvrcarCost.setRangeType(0);//rangeType
            jxsRepAvrcarCost.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepAvrcarCost.setTtlCostVal(carDealerTotal.get(i).get费用合计平均单店费用().setScale(2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAvrcarCost.setLcCostVal(carDealerTotal.get(i).get人工成本平均单车费用().setScale(2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAvrcarCost.setAdvCostVal(carDealerTotal.get(i).get广告平均单车费用().setScale(2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAvrcarCost.setFinCostVal(carDealerTotal.get(i).get财务平均单车费用().setScale(2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAvrcarCost.setOtCostVal(carDealerTotal.get(i).get其他平均单车费用().setScale(2, BigDecimal.ROUND_HALF_EVEN));

            resultList.add(jxsRepAvrcarCost);
        }

        try {
            databaseDao.deleteJxsRepAvrcarCost(yearId, quarterId);
            databaseDao.insertJxsRepAvrcarCost(resultList);

        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }

    }

    @Override
    public void handleJxsRepNcsTotalInfo(String yearId, String quarterId, List<DealerForm> dealerList, Map<String, Object> carMap,
                                         Map<String, Object> usedMap, Map<String, Object> saleMap, Map<String, Object> globalMap) {

        List<JxsRepNcsTotalInfo> resultList = new ArrayList<>();
        ObjectMapper objectMapper = new ObjectMapper();
        JxsRepNcsTotalInfo jxsRepNcsTotalInfo;

        //全国
        jxsRepNcsTotalInfo = new JxsRepNcsTotalInfo();
        jxsRepNcsTotalInfo.setId(getUUID());//ID
        jxsRepNcsTotalInfo.setYearId(yearId);//年份
        jxsRepNcsTotalInfo.setQuarterId(quarterId);//季度
        jxsRepNcsTotalInfo.setRangeType(4);//rangeType
        jxsRepNcsTotalInfo.setRevenueShare(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get新车收入占比());
        jxsRepNcsTotalInfo.setGml1RateTax(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get新车一级毛利率());
        jxsRepNcsTotalInfo.setGml2RateTax(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get新车二级毛利率());
        jxsRepNcsTotalInfo.setGml3RateTax(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get三级毛利率());
        jxsRepNcsTotalInfo.setRebateAvrevVal(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get新车业务平均单车返利().divide(BigDecimal.valueOf(1), 2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepNcsTotalInfo.setOdAvrevVal(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get平均单车衍生收入().divide(BigDecimal.valueOf(1), 2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepNcsTotalInfo.setAvrevGml3RateTax(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get平均单车三级毛利().divide(BigDecimal.valueOf(1), 2, BigDecimal.ROUND_HALF_EVEN));

        resultList.add(jxsRepNcsTotalInfo);

        //大区
        ArrayList<NewCarIndex> carArea = (ArrayList<NewCarIndex>) carMap.get("新车_区域");
        for (int i = 0; i < carArea.size(); i++) {
            jxsRepNcsTotalInfo = new JxsRepNcsTotalInfo();
            jxsRepNcsTotalInfo.setId(getUUID());//ID
            jxsRepNcsTotalInfo.setYearId(yearId);//年份
            jxsRepNcsTotalInfo.setQuarterId(quarterId);//季度
            jxsRepNcsTotalInfo.setRangeType(3);//rangeType
            jxsRepNcsTotalInfo.setJxsRegionId(carArea.get(i).get区域ID());
            jxsRepNcsTotalInfo.setRevenueShare(carArea.get(i).get新车收入占比());
            jxsRepNcsTotalInfo.setGml1RateTax(carArea.get(i).get新车一级毛利率());
            jxsRepNcsTotalInfo.setGml2RateTax(carArea.get(i).get新车二级毛利率());
            jxsRepNcsTotalInfo.setGml3RateTax(carArea.get(i).get三级毛利率());
            jxsRepNcsTotalInfo.setRebateAvrevVal(carArea.get(i).get新车业务平均单车返利().divide(BigDecimal.valueOf(1), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsTotalInfo.setOdAvrevVal(carArea.get(i).get平均单车衍生收入().divide(BigDecimal.valueOf(1), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsTotalInfo.setAvrevGml3RateTax(carArea.get(i).get平均单车三级毛利().divide(BigDecimal.valueOf(1), 2, BigDecimal.ROUND_HALF_EVEN));

            resultList.add(jxsRepNcsTotalInfo);
        }

        //经销商
        ArrayList<NewCarIndex> carDealer = (ArrayList<NewCarIndex>) carMap.get("新车_经销商");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepNcsTotalInfo = new JxsRepNcsTotalInfo();
            jxsRepNcsTotalInfo.setId(getUUID());//ID
            jxsRepNcsTotalInfo.setYearId(yearId);//年份
            jxsRepNcsTotalInfo.setQuarterId(quarterId);//季度
            jxsRepNcsTotalInfo.setRangeType(0);//rangeType
            jxsRepNcsTotalInfo.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepNcsTotalInfo.setRevenueShare(carDealer.get(i).get新车收入占比());
            jxsRepNcsTotalInfo.setGml1RateTax(carDealer.get(i).get新车一级毛利率());
            jxsRepNcsTotalInfo.setGml2RateTax(carDealer.get(i).get新车二级毛利率());
            jxsRepNcsTotalInfo.setGml3RateTax(carDealer.get(i).get三级毛利率());
            jxsRepNcsTotalInfo.setRebateAvrevVal(carDealer.get(i).get新车业务平均单车返利().divide(BigDecimal.valueOf(1), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsTotalInfo.setOdAvrevVal(carDealer.get(i).get平均单车衍生收入().divide(BigDecimal.valueOf(1), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsTotalInfo.setAvrevGml3RateTax(carDealer.get(i).get平均单车三级毛利().divide(BigDecimal.valueOf(1), 2, BigDecimal.ROUND_HALF_EVEN));

            resultList.add(jxsRepNcsTotalInfo);
        }

        try {
            databaseDao.deleteJxsRepNcsTotalInfo(yearId, quarterId);
            databaseDao.insertJxsRepNcsTotalInfo(resultList);


        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }


    }

    @Override
    public void handleJxsRepNcsGrossInfo(String yearId, String quarterId, List<DealerForm> dealerList, Map<String, Object> carMap,
                                         Map<String, Object> usedMap, Map<String, Object> saleMap, Map<String, Object> globalMap) {

        List<JxsRepNcsGrossInfo> resultList = new ArrayList<>();
        ObjectMapper objectMapper = new ObjectMapper();
        JxsRepNcsGrossInfo jxsRepNcsGrossInfo;

        //全国
        jxsRepNcsGrossInfo = new JxsRepNcsGrossInfo();
        jxsRepNcsGrossInfo.setId(getUUID());//ID
        jxsRepNcsGrossInfo.setYearId(yearId);//年份
        jxsRepNcsGrossInfo.setQuarterId(quarterId);//季度
        jxsRepNcsGrossInfo.setRangeType(4);//rangeType
        jxsRepNcsGrossInfo.setStatisType(1);//累计or当前
        jxsRepNcsGrossInfo.setGml1RateTax2(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get新车一级毛利率());
        jxsRepNcsGrossInfo.setGml1AvrevVal(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get平均单店新车毛利Ⅰ().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepNcsGrossInfo.setGml1AvrecVal(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get平均单车新车毛利Ⅰ());
        jxsRepNcsGrossInfo.setRebateRateTax2(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get新车返利对新车利润贡献率());
        jxsRepNcsGrossInfo.setRebateAvrevVal(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get平均单店新车返利().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepNcsGrossInfo.setRebateAvrecVal(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get新车业务平均单车返利());
        jxsRepNcsGrossInfo.setGml2RateTax2(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get新车二级毛利率());
        jxsRepNcsGrossInfo.setGml2AvrevVal(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get平均单店新车毛利Ⅱ().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepNcsGrossInfo.setGml2AvrecVal(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get平均单车新车毛利Ⅱ());
        jxsRepNcsGrossInfo.setRpRateTax2(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get精品备件衍生贡献());
        jxsRepNcsGrossInfo.setRpAvrevVal(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get平均单店精品备件衍生().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepNcsGrossInfo.setRpAvrecVal(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get平均单车精品备件衍生());
        jxsRepNcsGrossInfo.setFinRateTax2(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get金融衍生贡献());
        jxsRepNcsGrossInfo.setFinAvrevVal(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get平均单店金融衍生().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepNcsGrossInfo.setFinAvrecVal(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get平均单车金融衍生());
        jxsRepNcsGrossInfo.setInsRateTax2(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get保险衍生贡献());
        jxsRepNcsGrossInfo.setInsAvrevVal(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get平均单店保险衍生().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepNcsGrossInfo.setInsAvrecVal(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get平均单车保险衍生());
        jxsRepNcsGrossInfo.setOdRateTax2(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get其他衍生贡献());
        jxsRepNcsGrossInfo.setOdAvrevVal(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get平均单店其他衍生().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepNcsGrossInfo.setOdAvrecVal(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get平均单车其他衍生());
        jxsRepNcsGrossInfo.setGml3RateTax2(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get三级毛利率());
        jxsRepNcsGrossInfo.setGml3AvrevVal(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get平均单店新车毛利Ⅲ().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepNcsGrossInfo.setGml3AvrecVal(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get平均单车三级毛利());

        resultList.add(jxsRepNcsGrossInfo);

        //全国
        jxsRepNcsGrossInfo = new JxsRepNcsGrossInfo();
        jxsRepNcsGrossInfo.setId(getUUID());//ID
        jxsRepNcsGrossInfo.setYearId(yearId);//年份
        jxsRepNcsGrossInfo.setQuarterId(quarterId);//季度
        jxsRepNcsGrossInfo.setRangeType(4);//rangeType
        jxsRepNcsGrossInfo.setStatisType(0);//累计or当前
        jxsRepNcsGrossInfo.setGml1RateTax2(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get新车一级毛利率());
        jxsRepNcsGrossInfo.setGml1AvrevVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get平均单店新车毛利Ⅰ().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepNcsGrossInfo.setGml1AvrecVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get平均单车新车毛利Ⅰ());
        jxsRepNcsGrossInfo.setRebateRateTax2(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get新车返利对新车利润贡献率());
        jxsRepNcsGrossInfo.setRebateAvrevVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get平均单店新车返利().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepNcsGrossInfo.setRebateAvrecVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get新车业务平均单车返利());
        jxsRepNcsGrossInfo.setGml2RateTax2(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get新车二级毛利率());
        jxsRepNcsGrossInfo.setGml2AvrevVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get平均单店新车毛利Ⅱ().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepNcsGrossInfo.setGml2AvrecVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get平均单车新车毛利Ⅱ());
        jxsRepNcsGrossInfo.setRpRateTax2(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get精品备件衍生贡献());
        jxsRepNcsGrossInfo.setRpAvrevVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get平均单店精品备件衍生().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepNcsGrossInfo.setRpAvrecVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get平均单车精品备件衍生());
        jxsRepNcsGrossInfo.setFinRateTax2(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get金融衍生贡献());
        jxsRepNcsGrossInfo.setFinAvrevVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get平均单店金融衍生().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepNcsGrossInfo.setFinAvrecVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get平均单车金融衍生());
        jxsRepNcsGrossInfo.setInsRateTax2(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get保险衍生贡献());
        jxsRepNcsGrossInfo.setInsAvrevVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get平均单店保险衍生().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepNcsGrossInfo.setInsAvrecVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get平均单车保险衍生());
        jxsRepNcsGrossInfo.setOdRateTax2(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get其他衍生贡献());
        jxsRepNcsGrossInfo.setOdAvrevVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get平均单店其他衍生().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepNcsGrossInfo.setOdAvrecVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get平均单车其他衍生());
        jxsRepNcsGrossInfo.setGml3RateTax2(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get三级毛利率());
        jxsRepNcsGrossInfo.setGml3AvrevVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get平均单店新车毛利Ⅲ().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepNcsGrossInfo.setGml3AvrecVal(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get平均单车三级毛利());

        resultList.add(jxsRepNcsGrossInfo);

        //大区
        ArrayList<NewCarIndex> carArea = (ArrayList<NewCarIndex>) carMap.get("新车_区域");
        for (int i = 0; i < carArea.size(); i++) {
            jxsRepNcsGrossInfo = new JxsRepNcsGrossInfo();
            jxsRepNcsGrossInfo.setId(getUUID());//ID
            jxsRepNcsGrossInfo.setYearId(yearId);//年份
            jxsRepNcsGrossInfo.setQuarterId(quarterId);//季度
            jxsRepNcsGrossInfo.setRangeType(3);//rangeType
            jxsRepNcsGrossInfo.setStatisType(1);//累计or当前
            jxsRepNcsGrossInfo.setJxsRegionId(carArea.get(i).get区域ID());
            jxsRepNcsGrossInfo.setGml1RateTax2(carArea.get(i).get新车一级毛利率());
            jxsRepNcsGrossInfo.setGml1AvrevVal(carArea.get(i).get平均单店新车毛利Ⅰ().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setGml1AvrecVal(carArea.get(i).get平均单车新车毛利Ⅰ());
            jxsRepNcsGrossInfo.setRebateRateTax2(carArea.get(i).get新车返利对新车利润贡献率());
            jxsRepNcsGrossInfo.setRebateAvrevVal(carArea.get(i).get平均单店新车返利().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setRebateAvrecVal(carArea.get(i).get新车业务平均单车返利());
            jxsRepNcsGrossInfo.setGml2RateTax2(carArea.get(i).get新车二级毛利率());
            jxsRepNcsGrossInfo.setGml2AvrevVal(carArea.get(i).get平均单店新车毛利Ⅱ().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setGml2AvrecVal(carArea.get(i).get平均单车新车毛利Ⅱ());
            jxsRepNcsGrossInfo.setRpRateTax2(carArea.get(i).get精品备件衍生贡献());
            jxsRepNcsGrossInfo.setRpAvrevVal(carArea.get(i).get平均单店精品备件衍生().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setRpAvrecVal(carArea.get(i).get平均单车精品备件衍生());
            jxsRepNcsGrossInfo.setFinRateTax2(carArea.get(i).get金融衍生贡献());
            jxsRepNcsGrossInfo.setFinAvrevVal(carArea.get(i).get平均单店金融衍生().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setFinAvrecVal(carArea.get(i).get平均单车金融衍生());
            jxsRepNcsGrossInfo.setInsRateTax2(carArea.get(i).get保险衍生贡献());
            jxsRepNcsGrossInfo.setInsAvrevVal(carArea.get(i).get平均单店保险衍生().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setInsAvrecVal(carArea.get(i).get平均单车保险衍生());
            jxsRepNcsGrossInfo.setOdRateTax2(carArea.get(i).get其他衍生贡献());
            jxsRepNcsGrossInfo.setOdAvrevVal(carArea.get(i).get平均单店其他衍生().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setOdAvrecVal(carArea.get(i).get平均单车其他衍生());
            jxsRepNcsGrossInfo.setGml3RateTax2(carArea.get(i).get三级毛利率());
            jxsRepNcsGrossInfo.setGml3AvrevVal(carArea.get(i).get平均单店新车毛利Ⅲ().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setGml3AvrecVal(carArea.get(i).get平均单车三级毛利());
            resultList.add(jxsRepNcsGrossInfo);
        }

        //大区
        ArrayList<NewCarIndex> carAreaTotal = (ArrayList<NewCarIndex>) carMap.get("新车_区域累计");
        for (int i = 0; i < carArea.size(); i++) {
            jxsRepNcsGrossInfo = new JxsRepNcsGrossInfo();
            jxsRepNcsGrossInfo.setId(getUUID());//ID
            jxsRepNcsGrossInfo.setYearId(yearId);//年份
            jxsRepNcsGrossInfo.setQuarterId(quarterId);//季度
            jxsRepNcsGrossInfo.setRangeType(3);//rangeType
            jxsRepNcsGrossInfo.setStatisType(0);//累计or当前
            jxsRepNcsGrossInfo.setJxsRegionId(carAreaTotal.get(i).get区域ID());
            jxsRepNcsGrossInfo.setGml1RateTax2(carAreaTotal.get(i).get新车一级毛利率());
            jxsRepNcsGrossInfo.setGml1AvrevVal(carAreaTotal.get(i).get平均单店新车毛利Ⅰ().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setGml1AvrecVal(carAreaTotal.get(i).get平均单车新车毛利Ⅰ());
            jxsRepNcsGrossInfo.setRebateRateTax2(carAreaTotal.get(i).get新车返利对新车利润贡献率());
            jxsRepNcsGrossInfo.setRebateAvrevVal(carAreaTotal.get(i).get平均单店新车返利().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setRebateAvrecVal(carAreaTotal.get(i).get新车业务平均单车返利());
            jxsRepNcsGrossInfo.setGml2RateTax2(carAreaTotal.get(i).get新车二级毛利率());
            jxsRepNcsGrossInfo.setGml2AvrevVal(carAreaTotal.get(i).get平均单店新车毛利Ⅱ().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setGml2AvrecVal(carAreaTotal.get(i).get平均单车新车毛利Ⅱ());
            jxsRepNcsGrossInfo.setRpRateTax2(carAreaTotal.get(i).get精品备件衍生贡献());
            jxsRepNcsGrossInfo.setRpAvrevVal(carAreaTotal.get(i).get平均单店精品备件衍生().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setRpAvrecVal(carAreaTotal.get(i).get平均单车精品备件衍生());
            jxsRepNcsGrossInfo.setFinRateTax2(carAreaTotal.get(i).get金融衍生贡献());
            jxsRepNcsGrossInfo.setFinAvrevVal(carAreaTotal.get(i).get平均单店金融衍生().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setFinAvrecVal(carAreaTotal.get(i).get平均单车金融衍生());
            jxsRepNcsGrossInfo.setInsRateTax2(carAreaTotal.get(i).get保险衍生贡献());
            jxsRepNcsGrossInfo.setInsAvrevVal(carAreaTotal.get(i).get平均单店保险衍生().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setInsAvrecVal(carAreaTotal.get(i).get平均单车保险衍生());
            jxsRepNcsGrossInfo.setOdRateTax2(carAreaTotal.get(i).get其他衍生贡献());
            jxsRepNcsGrossInfo.setOdAvrevVal(carAreaTotal.get(i).get平均单店其他衍生().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setOdAvrecVal(carAreaTotal.get(i).get平均单车其他衍生());
            jxsRepNcsGrossInfo.setGml3RateTax2(carAreaTotal.get(i).get三级毛利率());
            jxsRepNcsGrossInfo.setGml3AvrevVal(carAreaTotal.get(i).get平均单店新车毛利Ⅲ().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setGml3AvrecVal(carAreaTotal.get(i).get平均单车三级毛利());

            resultList.add(jxsRepNcsGrossInfo);
        }

        //经销商
        ArrayList<NewCarIndex> carDealer = (ArrayList<NewCarIndex>) carMap.get("新车_经销商");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepNcsGrossInfo = new JxsRepNcsGrossInfo();
            jxsRepNcsGrossInfo.setId(getUUID());//ID
            jxsRepNcsGrossInfo.setYearId(yearId);//年份
            jxsRepNcsGrossInfo.setQuarterId(quarterId);//季度
            jxsRepNcsGrossInfo.setRangeType(0);//rangeType
            jxsRepNcsGrossInfo.setStatisType(1);//累计or当前
            jxsRepNcsGrossInfo.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepNcsGrossInfo.setGml1RateTax2(carDealer.get(i).get新车一级毛利率());
            jxsRepNcsGrossInfo.setGml1AvrevVal(carDealer.get(i).get平均单店新车毛利Ⅰ().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setGml1AvrecVal(carDealer.get(i).get平均单车新车毛利Ⅰ());
            jxsRepNcsGrossInfo.setRebateRateTax2(carDealer.get(i).get新车返利对新车利润贡献率());
            jxsRepNcsGrossInfo.setRebateAvrevVal(carDealer.get(i).get平均单店新车返利().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setRebateAvrecVal(carDealer.get(i).get新车业务平均单车返利());
            jxsRepNcsGrossInfo.setGml2RateTax2(carDealer.get(i).get新车二级毛利率());
            jxsRepNcsGrossInfo.setGml2AvrevVal(carDealer.get(i).get平均单店新车毛利Ⅱ().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setGml2AvrecVal(carDealer.get(i).get平均单车新车毛利Ⅱ());
            jxsRepNcsGrossInfo.setRpRateTax2(carDealer.get(i).get精品备件衍生贡献());
            jxsRepNcsGrossInfo.setRpAvrevVal(carDealer.get(i).get平均单店精品备件衍生().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setRpAvrecVal(carDealer.get(i).get平均单车精品备件衍生());
            jxsRepNcsGrossInfo.setFinRateTax2(carDealer.get(i).get金融衍生贡献());
            jxsRepNcsGrossInfo.setFinAvrevVal(carDealer.get(i).get平均单店金融衍生().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setFinAvrecVal(carDealer.get(i).get平均单车金融衍生());
            jxsRepNcsGrossInfo.setInsRateTax2(carDealer.get(i).get保险衍生贡献());
            jxsRepNcsGrossInfo.setInsAvrevVal(carDealer.get(i).get平均单店保险衍生().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setInsAvrecVal(carDealer.get(i).get平均单车保险衍生());
            jxsRepNcsGrossInfo.setOdRateTax2(carDealer.get(i).get其他衍生贡献());
            jxsRepNcsGrossInfo.setOdAvrevVal(carDealer.get(i).get平均单店其他衍生().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setOdAvrecVal(carDealer.get(i).get平均单车其他衍生());
            jxsRepNcsGrossInfo.setGml3RateTax2(carDealer.get(i).get三级毛利率());
            jxsRepNcsGrossInfo.setGml3AvrevVal(carDealer.get(i).get平均单店新车毛利Ⅲ().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setGml3AvrecVal(carDealer.get(i).get平均单车三级毛利());

            resultList.add(jxsRepNcsGrossInfo);
        }

        //经销商
        ArrayList<NewCarIndex> carDealerTotal = (ArrayList<NewCarIndex>) carMap.get("新车_经销商累计");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepNcsGrossInfo = new JxsRepNcsGrossInfo();
            jxsRepNcsGrossInfo.setId(getUUID());//ID
            jxsRepNcsGrossInfo.setYearId(yearId);//年份
            jxsRepNcsGrossInfo.setQuarterId(quarterId);//季度
            jxsRepNcsGrossInfo.setRangeType(0);//rangeType
            jxsRepNcsGrossInfo.setStatisType(0);//累计or当前
            jxsRepNcsGrossInfo.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepNcsGrossInfo.setGml1RateTax2(carDealerTotal.get(i).get新车一级毛利率());
            jxsRepNcsGrossInfo.setGml1AvrevVal(carDealerTotal.get(i).get平均单店新车毛利Ⅰ().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setGml1AvrecVal(carDealerTotal.get(i).get平均单车新车毛利Ⅰ());
            jxsRepNcsGrossInfo.setRebateRateTax2(carDealerTotal.get(i).get新车返利对新车利润贡献率());
            jxsRepNcsGrossInfo.setRebateAvrevVal(carDealerTotal.get(i).get平均单店新车返利().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setRebateAvrecVal(carDealerTotal.get(i).get新车业务平均单车返利());
            jxsRepNcsGrossInfo.setGml2RateTax2(carDealerTotal.get(i).get新车二级毛利率());
            jxsRepNcsGrossInfo.setGml2AvrevVal(carDealerTotal.get(i).get平均单店新车毛利Ⅱ().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setGml2AvrecVal(carDealerTotal.get(i).get平均单车新车毛利Ⅱ());
            jxsRepNcsGrossInfo.setRpRateTax2(carDealerTotal.get(i).get精品备件衍生贡献());
            jxsRepNcsGrossInfo.setRpAvrevVal(carDealerTotal.get(i).get平均单店精品备件衍生().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setRpAvrecVal(carDealerTotal.get(i).get平均单车精品备件衍生());
            jxsRepNcsGrossInfo.setFinRateTax2(carDealerTotal.get(i).get金融衍生贡献());
            jxsRepNcsGrossInfo.setFinAvrevVal(carDealerTotal.get(i).get平均单店金融衍生().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setFinAvrecVal(carDealerTotal.get(i).get平均单车金融衍生());
            jxsRepNcsGrossInfo.setInsRateTax2(carDealerTotal.get(i).get保险衍生贡献());
            jxsRepNcsGrossInfo.setInsAvrevVal(carDealerTotal.get(i).get平均单店保险衍生().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setInsAvrecVal(carDealerTotal.get(i).get平均单车保险衍生());
            jxsRepNcsGrossInfo.setOdRateTax2(carDealerTotal.get(i).get其他衍生贡献());
            jxsRepNcsGrossInfo.setOdAvrevVal(carDealerTotal.get(i).get平均单店其他衍生().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setOdAvrecVal(carDealerTotal.get(i).get平均单车其他衍生());
            jxsRepNcsGrossInfo.setGml3RateTax2(carDealerTotal.get(i).get三级毛利率());
            jxsRepNcsGrossInfo.setGml3AvrevVal(carDealerTotal.get(i).get平均单店新车毛利Ⅲ().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepNcsGrossInfo.setGml3AvrecVal(carDealerTotal.get(i).get平均单车三级毛利());

            resultList.add(jxsRepNcsGrossInfo);
        }

        try {
            databaseDao.deleteJxsRepNcsGrossInfo(yearId, quarterId);
            databaseDao.insertJxsRepNcsGrossInfo(resultList);


        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }


    }

    @Override
    public void handleJxsRepNcsGrossPro(String yearId, String quarterId, List<DealerForm> dealerList, Map<String, Object> carMap,
                                        Map<String, Object> usedMap, Map<String, Object> saleMap, Map<String, Object> globalMap) {

        List<JxsRepNcsGrossPro> resultList = new ArrayList<>();
        ObjectMapper objectMapper = new ObjectMapper();
        JxsRepNcsGrossPro jxsRepNcsGrossPro;

        //全国
        jxsRepNcsGrossPro = new JxsRepNcsGrossPro();
        jxsRepNcsGrossPro.setId(getUUID());//ID
        jxsRepNcsGrossPro.setYearId(yearId);//年份
        jxsRepNcsGrossPro.setQuarterId(quarterId);//季度
        jxsRepNcsGrossPro.setRangeType(4);//rangeType
        jxsRepNcsGrossPro.setStatisType(1);//累计or当前
        jxsRepNcsGrossPro.setGml1RateTax(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get新车毛利Ⅰ对新车利润贡献率());
        jxsRepNcsGrossPro.setGml2RateTax(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get新车毛利Ⅱ对新车利润贡献率());
        jxsRepNcsGrossPro.setGml3RateTax(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get三级毛利率());

        resultList.add(jxsRepNcsGrossPro);

        //全国
        jxsRepNcsGrossPro = new JxsRepNcsGrossPro();
        jxsRepNcsGrossPro.setId(getUUID());//ID
        jxsRepNcsGrossPro.setYearId(yearId);//年份
        jxsRepNcsGrossPro.setQuarterId(quarterId);//季度
        jxsRepNcsGrossPro.setRangeType(4);//rangeType
        jxsRepNcsGrossPro.setStatisType(0);//累计or当前
        jxsRepNcsGrossPro.setGml1RateTax(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get新车毛利Ⅰ对新车利润贡献率());
        jxsRepNcsGrossPro.setGml2RateTax(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get新车毛利Ⅱ对新车利润贡献率());
        jxsRepNcsGrossPro.setGml3RateTax(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get三级毛利率());

        resultList.add(jxsRepNcsGrossPro);

        //大区
        ArrayList<NewCarIndex> carArea = (ArrayList<NewCarIndex>) carMap.get("新车_区域");
        for (int i = 0; i < carArea.size(); i++) {
            jxsRepNcsGrossPro = new JxsRepNcsGrossPro();
            jxsRepNcsGrossPro.setId(getUUID());//ID
            jxsRepNcsGrossPro.setYearId(yearId);//年份
            jxsRepNcsGrossPro.setQuarterId(quarterId);//季度
            jxsRepNcsGrossPro.setRangeType(3);//rangeType
            jxsRepNcsGrossPro.setStatisType(1);//累计or当前
            jxsRepNcsGrossPro.setJxsRegionId(carArea.get(i).get区域ID());
            jxsRepNcsGrossPro.setGml1RateTax(carArea.get(i).get新车毛利Ⅰ对新车利润贡献率());
            jxsRepNcsGrossPro.setGml2RateTax(carArea.get(i).get新车毛利Ⅱ对新车利润贡献率());
            jxsRepNcsGrossPro.setGml3RateTax(carArea.get(i).get三级毛利率());

            resultList.add(jxsRepNcsGrossPro);
        }

        //大区
        ArrayList<NewCarIndex> carAreaTotal = (ArrayList<NewCarIndex>) carMap.get("新车_区域累计");
        for (int i = 0; i < carArea.size(); i++) {
            jxsRepNcsGrossPro = new JxsRepNcsGrossPro();
            jxsRepNcsGrossPro.setId(getUUID());//ID
            jxsRepNcsGrossPro.setYearId(yearId);//年份
            jxsRepNcsGrossPro.setQuarterId(quarterId);//季度
            jxsRepNcsGrossPro.setRangeType(3);//rangeType
            jxsRepNcsGrossPro.setStatisType(0);//累计or当前
            jxsRepNcsGrossPro.setJxsRegionId(carAreaTotal.get(i).get区域ID());
            jxsRepNcsGrossPro.setGml1RateTax(carAreaTotal.get(i).get新车毛利Ⅰ对新车利润贡献率());
            jxsRepNcsGrossPro.setGml2RateTax(carAreaTotal.get(i).get新车毛利Ⅱ对新车利润贡献率());
            jxsRepNcsGrossPro.setGml3RateTax(carAreaTotal.get(i).get三级毛利率());

            resultList.add(jxsRepNcsGrossPro);
        }

        //经销商
        ArrayList<NewCarIndex> carDealer = (ArrayList<NewCarIndex>) carMap.get("新车_经销商");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepNcsGrossPro = new JxsRepNcsGrossPro();
            jxsRepNcsGrossPro.setId(getUUID());//ID
            jxsRepNcsGrossPro.setYearId(yearId);//年份
            jxsRepNcsGrossPro.setQuarterId(quarterId);//季度
            jxsRepNcsGrossPro.setRangeType(0);//rangeType
            jxsRepNcsGrossPro.setStatisType(1);//累计or当前
            jxsRepNcsGrossPro.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepNcsGrossPro.setGml1RateTax(carDealer.get(i).get新车毛利Ⅰ对新车利润贡献率());
            jxsRepNcsGrossPro.setGml2RateTax(carDealer.get(i).get新车毛利Ⅱ对新车利润贡献率());
            jxsRepNcsGrossPro.setGml3RateTax(carDealer.get(i).get三级毛利率());

            resultList.add(jxsRepNcsGrossPro);
        }

        //经销商
        ArrayList<NewCarIndex> carDealerTotal = (ArrayList<NewCarIndex>) carMap.get("新车_经销商累计");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepNcsGrossPro = new JxsRepNcsGrossPro();
            jxsRepNcsGrossPro.setId(getUUID());//ID
            jxsRepNcsGrossPro.setYearId(yearId);//年份
            jxsRepNcsGrossPro.setQuarterId(quarterId);//季度
            jxsRepNcsGrossPro.setRangeType(0);//rangeType
            jxsRepNcsGrossPro.setStatisType(0);//累计or当前
            jxsRepNcsGrossPro.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepNcsGrossPro.setGml1RateTax(carDealerTotal.get(i).get新车毛利Ⅰ对新车利润贡献率());
            jxsRepNcsGrossPro.setGml2RateTax(carDealerTotal.get(i).get新车毛利Ⅱ对新车利润贡献率());
            jxsRepNcsGrossPro.setGml3RateTax(carDealerTotal.get(i).get三级毛利率());

            resultList.add(jxsRepNcsGrossPro);
        }

        try {
            databaseDao.deleteJxsRepNcsGrossPro(yearId, quarterId);
            databaseDao.insertJxsRepNcsGrossPro(resultList);


        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }


    }

    @Override
    public void handleJxsRepNcsDerMange(String yearId, String quarterId, List<DealerForm> dealerList, Map<String, Object> carMap,
                                        Map<String, Object> usedMap, Map<String, Object> saleMap, Map<String, Object> globalMap) {

        List<JxsRepNcsDerMange> resultList = new ArrayList<>();
        ObjectMapper objectMapper = new ObjectMapper();
        JxsRepNcsDerMange jxsRepNcsDerMange;

        //全国
        jxsRepNcsDerMange = new JxsRepNcsDerMange();
        jxsRepNcsDerMange.setId(getUUID());//ID
        jxsRepNcsDerMange.setYearId(yearId);//年份
        jxsRepNcsDerMange.setQuarterId(quarterId);//季度
        jxsRepNcsDerMange.setRangeType(4);//rangeType
        jxsRepNcsDerMange.setStatisType(1);//累计or当前
        jxsRepNcsDerMange.setRpScIncome(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get精品加装平均单车());
        jxsRepNcsDerMange.setRpPeneRate(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get精品加装渗透率());
        jxsRepNcsDerMange.setConCreScIncome(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get消费信贷平均单车());
        jxsRepNcsDerMange.setConCrePeneRate(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get消费信贷渗透率());
        jxsRepNcsDerMange.setFinLeaseScIncome(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get融资租赁平均单车());
        jxsRepNcsDerMange.setFinLeasePeneRate(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get融资租赁渗透率());
        jxsRepNcsDerMange.setInsScIncome(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get新车保险平均单车());
        jxsRepNcsDerMange.setInsPeneRate(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get新车保险渗透率());
        jxsRepNcsDerMange.setOdScIncome(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get上牌及其他平均单车());
        jxsRepNcsDerMange.setOdPeneRate(objectMapper.convertValue(carMap.get("新车_全国"), NewCarIndex.class).get上牌及其他渗透率());

        resultList.add(jxsRepNcsDerMange);

        //全国
        jxsRepNcsDerMange = new JxsRepNcsDerMange();
        jxsRepNcsDerMange.setId(getUUID());//ID
        jxsRepNcsDerMange.setYearId(yearId);//年份
        jxsRepNcsDerMange.setQuarterId(quarterId);//季度
        jxsRepNcsDerMange.setRangeType(4);//rangeType
        jxsRepNcsDerMange.setStatisType(0);//累计or当前
        jxsRepNcsDerMange.setRpScIncome(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get精品加装平均单车());
        jxsRepNcsDerMange.setRpPeneRate(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get精品加装渗透率());
        jxsRepNcsDerMange.setConCreScIncome(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get消费信贷平均单车());
        jxsRepNcsDerMange.setConCrePeneRate(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get消费信贷渗透率());
        jxsRepNcsDerMange.setFinLeaseScIncome(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get融资租赁平均单车());
        jxsRepNcsDerMange.setFinLeasePeneRate(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get融资租赁渗透率());
        jxsRepNcsDerMange.setInsScIncome(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get新车保险平均单车());
        jxsRepNcsDerMange.setInsPeneRate(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get新车保险渗透率());
        jxsRepNcsDerMange.setOdScIncome(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get上牌及其他平均单车());
        jxsRepNcsDerMange.setOdPeneRate(objectMapper.convertValue(carMap.get("新车_全国累计"), NewCarIndex.class).get上牌及其他渗透率());

        resultList.add(jxsRepNcsDerMange);

        //大区
        ArrayList<NewCarIndex> carArea = (ArrayList<NewCarIndex>) carMap.get("新车_区域");
        for (int i = 0; i < carArea.size(); i++) {
            jxsRepNcsDerMange = new JxsRepNcsDerMange();
            jxsRepNcsDerMange.setId(getUUID());//ID
            jxsRepNcsDerMange.setYearId(yearId);//年份
            jxsRepNcsDerMange.setQuarterId(quarterId);//季度
            jxsRepNcsDerMange.setRangeType(3);//rangeType
            jxsRepNcsDerMange.setStatisType(1);//累计or当前
            jxsRepNcsDerMange.setJxsRegionId(carArea.get(i).get区域ID());
            jxsRepNcsDerMange.setRpScIncome(carArea.get(i).get精品加装平均单车());
            jxsRepNcsDerMange.setRpPeneRate(carArea.get(i).get精品加装渗透率());
            jxsRepNcsDerMange.setConCreScIncome(carArea.get(i).get消费信贷平均单车());
            jxsRepNcsDerMange.setConCrePeneRate(carArea.get(i).get消费信贷渗透率());
            jxsRepNcsDerMange.setFinLeaseScIncome(carArea.get(i).get融资租赁平均单车());
            jxsRepNcsDerMange.setFinLeasePeneRate(carArea.get(i).get融资租赁渗透率());
            jxsRepNcsDerMange.setInsScIncome(carArea.get(i).get新车保险平均单车());
            jxsRepNcsDerMange.setInsPeneRate(carArea.get(i).get新车保险渗透率());
            jxsRepNcsDerMange.setOdScIncome(carArea.get(i).get上牌及其他平均单车());
            jxsRepNcsDerMange.setOdPeneRate(carArea.get(i).get上牌及其他渗透率());

            resultList.add(jxsRepNcsDerMange);
        }

        //大区
        ArrayList<NewCarIndex> carAreaTotal = (ArrayList<NewCarIndex>) carMap.get("新车_区域累计");
        for (int i = 0; i < carArea.size(); i++) {
            jxsRepNcsDerMange = new JxsRepNcsDerMange();
            jxsRepNcsDerMange.setId(getUUID());//ID
            jxsRepNcsDerMange.setYearId(yearId);//年份
            jxsRepNcsDerMange.setQuarterId(quarterId);//季度
            jxsRepNcsDerMange.setRangeType(3);//rangeType
            jxsRepNcsDerMange.setStatisType(0);//累计or当前
            jxsRepNcsDerMange.setJxsRegionId(carAreaTotal.get(i).get区域ID());
            jxsRepNcsDerMange.setRpScIncome(carAreaTotal.get(i).get精品加装平均单车());
            jxsRepNcsDerMange.setRpPeneRate(carAreaTotal.get(i).get精品加装渗透率());
            jxsRepNcsDerMange.setConCreScIncome(carAreaTotal.get(i).get消费信贷平均单车());
            jxsRepNcsDerMange.setConCrePeneRate(carAreaTotal.get(i).get消费信贷渗透率());
            jxsRepNcsDerMange.setFinLeaseScIncome(carAreaTotal.get(i).get融资租赁平均单车());
            jxsRepNcsDerMange.setFinLeasePeneRate(carAreaTotal.get(i).get融资租赁渗透率());
            jxsRepNcsDerMange.setInsScIncome(carAreaTotal.get(i).get新车保险平均单车());
            jxsRepNcsDerMange.setInsPeneRate(carAreaTotal.get(i).get新车保险渗透率());
            jxsRepNcsDerMange.setOdScIncome(carAreaTotal.get(i).get上牌及其他平均单车());
            jxsRepNcsDerMange.setOdPeneRate(carAreaTotal.get(i).get上牌及其他渗透率());

            resultList.add(jxsRepNcsDerMange);
        }

        //经销商
        ArrayList<NewCarIndex> carDealer = (ArrayList<NewCarIndex>) carMap.get("新车_经销商");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepNcsDerMange = new JxsRepNcsDerMange();
            jxsRepNcsDerMange.setId(getUUID());//ID
            jxsRepNcsDerMange.setYearId(yearId);//年份
            jxsRepNcsDerMange.setQuarterId(quarterId);//季度
            jxsRepNcsDerMange.setRangeType(0);//rangeType
            jxsRepNcsDerMange.setStatisType(1);//累计or当前
            jxsRepNcsDerMange.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepNcsDerMange.setRpScIncome(carDealer.get(i).get精品加装平均单车());
            jxsRepNcsDerMange.setRpPeneRate(carDealer.get(i).get精品加装渗透率());
            jxsRepNcsDerMange.setConCreScIncome(carDealer.get(i).get消费信贷平均单车());
            jxsRepNcsDerMange.setConCrePeneRate(carDealer.get(i).get消费信贷渗透率());
            jxsRepNcsDerMange.setFinLeaseScIncome(carDealer.get(i).get融资租赁平均单车());
            jxsRepNcsDerMange.setFinLeasePeneRate(carDealer.get(i).get融资租赁渗透率());
            jxsRepNcsDerMange.setInsScIncome(carDealer.get(i).get新车保险平均单车());
            jxsRepNcsDerMange.setInsPeneRate(carDealer.get(i).get新车保险渗透率());
            jxsRepNcsDerMange.setOdScIncome(carDealer.get(i).get上牌及其他平均单车());
            jxsRepNcsDerMange.setOdPeneRate(carDealer.get(i).get上牌及其他渗透率());

            resultList.add(jxsRepNcsDerMange);
        }

        //经销商
        ArrayList<NewCarIndex> carDealerTotal = (ArrayList<NewCarIndex>) carMap.get("新车_经销商累计");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepNcsDerMange = new JxsRepNcsDerMange();
            jxsRepNcsDerMange.setId(getUUID());//ID
            jxsRepNcsDerMange.setYearId(yearId);//年份
            jxsRepNcsDerMange.setQuarterId(quarterId);//季度
            jxsRepNcsDerMange.setRangeType(0);//rangeType
            jxsRepNcsDerMange.setStatisType(0);//累计or当前
            jxsRepNcsDerMange.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepNcsDerMange.setRpScIncome(carDealerTotal.get(i).get精品加装平均单车());
            jxsRepNcsDerMange.setRpPeneRate(carDealerTotal.get(i).get精品加装渗透率());
            jxsRepNcsDerMange.setConCreScIncome(carDealerTotal.get(i).get消费信贷平均单车());
            jxsRepNcsDerMange.setConCrePeneRate(carDealerTotal.get(i).get消费信贷渗透率());
            jxsRepNcsDerMange.setFinLeaseScIncome(carDealerTotal.get(i).get融资租赁平均单车());
            jxsRepNcsDerMange.setFinLeasePeneRate(carDealerTotal.get(i).get融资租赁渗透率());
            jxsRepNcsDerMange.setInsScIncome(carDealerTotal.get(i).get新车保险平均单车());
            jxsRepNcsDerMange.setInsPeneRate(carDealerTotal.get(i).get新车保险渗透率());
            jxsRepNcsDerMange.setOdScIncome(carDealerTotal.get(i).get上牌及其他平均单车());
            jxsRepNcsDerMange.setOdPeneRate(carDealerTotal.get(i).get上牌及其他渗透率());

            resultList.add(jxsRepNcsDerMange);
        }

        try {
            databaseDao.deleteJxsRepNcsDerMange(yearId, quarterId);
            databaseDao.insertJxsRepNcsDerMange(resultList);


        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }


    }

    @Override
    public void handleJxsRepAsTotalInfo(String yearId, String quarterId, List<DealerForm> dealerList, Map<String, Object> carMap,
                                        Map<String, Object> usedMap, Map<String, Object> saleMap, Map<String, Object> globalMap) throws NoSuchAlgorithmException {

        List<JxsRepAsTotalInfo> resultList = new ArrayList<>();
        ObjectMapper objectMapper = new ObjectMapper();
        JxsRepAsTotalInfo jxsRepAsTotalInfo;

        //全国
        jxsRepAsTotalInfo = new JxsRepAsTotalInfo();
        jxsRepAsTotalInfo.setId(getSecureRandom());//ID
        jxsRepAsTotalInfo.setYearId(yearId);//年份
        jxsRepAsTotalInfo.setQuarterId(quarterId);//季度
        jxsRepAsTotalInfo.setRangeType(4);//rangeType
        jxsRepAsTotalInfo.setAsOutput(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get平均单店售后产值());
        jxsRepAsTotalInfo.setEnterNum(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get售后进厂台次平均单店().divide(BigDecimal.valueOf(1), 2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAsTotalInfo.setAvrevAsOutput(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get售后单车产值().divide(BigDecimal.valueOf(1), 2, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAsTotalInfo.setGml1RateTax(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get售后一级毛利率());
        jxsRepAsTotalInfo.setGml2RateTax(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get售后二级毛利率());
        jxsRepAsTotalInfo.setGml3RateTax(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get售后三级毛利率());
        jxsRepAsTotalInfo.setPartRebate(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get平均单店售后返利());
        jxsRepAsTotalInfo.setDerIncome(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get平均单店售后衍生业务收入());

        resultList.add(jxsRepAsTotalInfo);

        //大区
        ArrayList<AfterSaleIndex> afterSaleArea = (ArrayList<AfterSaleIndex>) saleMap.get("售后_区域");
        for (int i = 0; i < afterSaleArea.size(); i++) {
            jxsRepAsTotalInfo = new JxsRepAsTotalInfo();
            jxsRepAsTotalInfo.setId(getSecureRandom());//ID
            jxsRepAsTotalInfo.setYearId(yearId);//年份
            jxsRepAsTotalInfo.setQuarterId(quarterId);//季度
            jxsRepAsTotalInfo.setRangeType(3);//rangeType
            jxsRepAsTotalInfo.setJxsRegionId(afterSaleArea.get(i).get区域ID());
            jxsRepAsTotalInfo.setAsOutput(afterSaleArea.get(i).get平均单店售后产值());
            jxsRepAsTotalInfo.setEnterNum(afterSaleArea.get(i).get售后进厂台次平均单店().divide(BigDecimal.valueOf(1), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsTotalInfo.setAvrevAsOutput(afterSaleArea.get(i).get售后单车产值().divide(BigDecimal.valueOf(1), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsTotalInfo.setGml1RateTax(afterSaleArea.get(i).get售后一级毛利率());
            jxsRepAsTotalInfo.setGml2RateTax(afterSaleArea.get(i).get售后二级毛利率());
            jxsRepAsTotalInfo.setGml3RateTax(afterSaleArea.get(i).get售后三级毛利率());
            jxsRepAsTotalInfo.setPartRebate(afterSaleArea.get(i).get平均单店售后返利());
            jxsRepAsTotalInfo.setDerIncome(afterSaleArea.get(i).get平均单店售后衍生业务收入());

            resultList.add(jxsRepAsTotalInfo);
        }

        //经销商
        ArrayList<AfterSaleIndex> afterSaleDealer = (ArrayList<AfterSaleIndex>) saleMap.get("售后_经销商");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepAsTotalInfo = new JxsRepAsTotalInfo();
            jxsRepAsTotalInfo.setId(getSecureRandom());//ID
            jxsRepAsTotalInfo.setYearId(yearId);//年份
            jxsRepAsTotalInfo.setQuarterId(quarterId);//季度
            jxsRepAsTotalInfo.setRangeType(0);//rangeType
            jxsRepAsTotalInfo.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepAsTotalInfo.setAsOutput(afterSaleDealer.get(i).get平均单店售后产值());
            jxsRepAsTotalInfo.setEnterNum(afterSaleDealer.get(i).get售后进厂台次平均单店().divide(BigDecimal.valueOf(1), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsTotalInfo.setAvrevAsOutput(afterSaleDealer.get(i).get售后单车产值().divide(BigDecimal.valueOf(1), 2, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsTotalInfo.setGml1RateTax(afterSaleDealer.get(i).get售后一级毛利率());
            jxsRepAsTotalInfo.setGml2RateTax(afterSaleDealer.get(i).get售后二级毛利率());
            jxsRepAsTotalInfo.setGml3RateTax(afterSaleDealer.get(i).get售后三级毛利率());
            jxsRepAsTotalInfo.setPartRebate(afterSaleDealer.get(i).get平均单店售后返利());
            jxsRepAsTotalInfo.setDerIncome(afterSaleDealer.get(i).get平均单店售后衍生业务收入());

            resultList.add(jxsRepAsTotalInfo);
        }

        try {
            databaseDao.deleteJxsRepAsTotalInfo(yearId, quarterId);
            databaseDao.insertJxsRepAsTotalInfo(resultList);


        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }


    }

    @Override
    public void handleJxsRepAsGrossPro(String yearId, String quarterId, List<DealerForm> dealerList, Map<String, Object> carMap,
                                       Map<String, Object> usedMap, Map<String, Object> saleMap, Map<String, Object> globalMap) throws NoSuchAlgorithmException {

        List<JxsRepAsGrossPro> resultList = new ArrayList<>();
        ObjectMapper objectMapper = new ObjectMapper();
        JxsRepAsGrossPro jxsRepAsGrossPro;

        //全国
        jxsRepAsGrossPro = new JxsRepAsGrossPro();
        jxsRepAsGrossPro.setId(getSecureRandom());//ID
        jxsRepAsGrossPro.setYearId(yearId);//年份
        jxsRepAsGrossPro.setQuarterId(quarterId);//季度
        jxsRepAsGrossPro.setRangeType(4);//rangeType
        jxsRepAsGrossPro.setStatisType(1);//累计or当前
        jxsRepAsGrossPro.setClaRateTax2(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get索赔毛利贡献());
        jxsRepAsGrossPro.setClaAvrevVal1(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get平均单店索赔贡献());
        jxsRepAsGrossPro.setUkRateTax2(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get保养毛利贡献());
        jxsRepAsGrossPro.setUkAvrevVal1(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get平均单店保养贡献());
        jxsRepAsGrossPro.setAcvRateTax2(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get事故车毛利贡献());
        jxsRepAsGrossPro.setAcvAvrevVal1(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get平均单店事故车贡献());
        jxsRepAsGrossPro.setSpRateTax2(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get自费毛利贡献());
        jxsRepAsGrossPro.setSpAvrevVal1(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get平均单店自费贡献());
        jxsRepAsGrossPro.setGml1RateTax2(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get售后毛利Ⅰ());
        jxsRepAsGrossPro.setGml1AvrevVal1(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get平均单店售后毛利Ⅰ());
        jxsRepAsGrossPro.setRpReRateTax2(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get备件返利贡献());
        jxsRepAsGrossPro.setRpReAvrevVal1(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get平均单店售后返利());
        jxsRepAsGrossPro.setGml2RateTax2(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get售后毛利Ⅱ());
        jxsRepAsGrossPro.setGml2AvrevVal1(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get平均单店售后毛利Ⅱ());
        jxsRepAsGrossPro.setRpRateTax2(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get售后精品备件衍生贡献());
        jxsRepAsGrossPro.setRpAvrevVal1(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get平均单店售后精品备件衍生());
        jxsRepAsGrossPro.setInsRateTax2(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get售后保险衍生贡献());
        jxsRepAsGrossPro.setInsAvrevVal1(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get平均单店售后保险衍生());
        jxsRepAsGrossPro.setGml3RateTax2(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get售后三级毛利率());
        jxsRepAsGrossPro.setGml3AvrevVal1(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get平均单店售后毛利Ⅲ());

        resultList.add(jxsRepAsGrossPro);

        jxsRepAsGrossPro = new JxsRepAsGrossPro();
        jxsRepAsGrossPro.setId(getSecureRandom());//ID
        jxsRepAsGrossPro.setYearId(yearId);//年份
        jxsRepAsGrossPro.setQuarterId(quarterId);//季度
        jxsRepAsGrossPro.setRangeType(4);//rangeType
        jxsRepAsGrossPro.setStatisType(0);//累计or当前
        jxsRepAsGrossPro.setClaRateTax2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get索赔毛利贡献());
        jxsRepAsGrossPro.setClaAvrevVal1(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店索赔贡献());
        jxsRepAsGrossPro.setClaAvrevVal2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单车索赔贡献());
        jxsRepAsGrossPro.setUkRateTax2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get保养毛利贡献());
        jxsRepAsGrossPro.setUkAvrevVal1(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店保养贡献());
        jxsRepAsGrossPro.setUkAvrevVal2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单车保养贡献());
        jxsRepAsGrossPro.setAcvRateTax2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get事故车毛利贡献());
        jxsRepAsGrossPro.setAcvAvrevVal1(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店事故车贡献());
        jxsRepAsGrossPro.setAcvAvrevVal2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单车事故车贡献());
        jxsRepAsGrossPro.setSpRateTax2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get自费毛利贡献());
        jxsRepAsGrossPro.setSpAvrevVal1(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店自费贡献());
        jxsRepAsGrossPro.setSpAvrevVal2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单车自费贡献());
        jxsRepAsGrossPro.setGml1RateTax2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get售后毛利Ⅰ());
        jxsRepAsGrossPro.setGml1AvrevVal1(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店售后毛利Ⅰ());
        jxsRepAsGrossPro.setGml1AvrevVal2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单车售后毛利Ⅰ());
        jxsRepAsGrossPro.setRpReRateTax2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get备件返利贡献());
        jxsRepAsGrossPro.setRpReAvrevVal1(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店售后返利());
        jxsRepAsGrossPro.setRpReAvrevVal2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单车售后返利());
        jxsRepAsGrossPro.setGml2RateTax2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get售后毛利Ⅱ());
        jxsRepAsGrossPro.setGml2AvrevVal1(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店售后毛利Ⅱ());
        jxsRepAsGrossPro.setGml2AvrevVal2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单车售后毛利Ⅱ());
        jxsRepAsGrossPro.setRpRateTax2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get售后精品备件衍生贡献());
        jxsRepAsGrossPro.setRpAvrevVal1(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店售后精品备件衍生());
        jxsRepAsGrossPro.setRpAvrevVal2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单车售后精品备件衍生());
        jxsRepAsGrossPro.setInsRateTax2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get售后保险衍生贡献());
        jxsRepAsGrossPro.setInsAvrevVal1(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店售后保险衍生());
        jxsRepAsGrossPro.setInsAvrevVal2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单车售后保险衍生());
        jxsRepAsGrossPro.setGml3RateTax2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get售后三级毛利率());
        jxsRepAsGrossPro.setGml3AvrevVal1(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店售后毛利Ⅲ());
        jxsRepAsGrossPro.setGml3AvrevVal2(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单车售后毛利Ⅲ());
        resultList.add(jxsRepAsGrossPro);

        //大区
        ArrayList<AfterSaleIndex> afterSaleArea = (ArrayList<AfterSaleIndex>) saleMap.get("售后_区域");
        for (int i = 0; i < afterSaleArea.size(); i++) {
            jxsRepAsGrossPro = new JxsRepAsGrossPro();
            jxsRepAsGrossPro.setId(getSecureRandom());//ID
            jxsRepAsGrossPro.setYearId(yearId);//年份
            jxsRepAsGrossPro.setQuarterId(quarterId);//季度
            jxsRepAsGrossPro.setRangeType(3);//rangeType
            jxsRepAsGrossPro.setStatisType(1);//累计or当前
            jxsRepAsGrossPro.setJxsRegionId(afterSaleArea.get(i).get区域ID());
            jxsRepAsGrossPro.setClaRateTax2(afterSaleArea.get(i).get索赔毛利贡献());
            jxsRepAsGrossPro.setClaAvrevVal1(afterSaleArea.get(i).get平均单店索赔贡献());
            jxsRepAsGrossPro.setUkRateTax2(afterSaleArea.get(i).get保养毛利贡献());
            jxsRepAsGrossPro.setUkAvrevVal1(afterSaleArea.get(i).get平均单店保养贡献());
            jxsRepAsGrossPro.setAcvRateTax2(afterSaleArea.get(i).get事故车毛利贡献());
            jxsRepAsGrossPro.setAcvAvrevVal1(afterSaleArea.get(i).get平均单店事故车贡献());
            jxsRepAsGrossPro.setSpRateTax2(afterSaleArea.get(i).get自费毛利贡献());
            jxsRepAsGrossPro.setSpAvrevVal1(afterSaleArea.get(i).get平均单店自费贡献());
            jxsRepAsGrossPro.setGml1RateTax2(afterSaleArea.get(i).get售后毛利Ⅰ());
            jxsRepAsGrossPro.setGml1AvrevVal1(afterSaleArea.get(i).get平均单店售后毛利Ⅰ());
            jxsRepAsGrossPro.setRpReRateTax2(afterSaleArea.get(i).get备件返利贡献());
            jxsRepAsGrossPro.setRpReAvrevVal1(afterSaleArea.get(i).get平均单店售后返利());
            jxsRepAsGrossPro.setGml2RateTax2(afterSaleArea.get(i).get售后毛利Ⅱ());
            jxsRepAsGrossPro.setGml2AvrevVal1(afterSaleArea.get(i).get平均单店售后毛利Ⅱ());
            jxsRepAsGrossPro.setRpRateTax2(afterSaleArea.get(i).get售后精品备件衍生贡献());
            jxsRepAsGrossPro.setRpAvrevVal1(afterSaleArea.get(i).get平均单店售后精品备件衍生());
            jxsRepAsGrossPro.setInsRateTax2(afterSaleArea.get(i).get售后保险衍生贡献());
            jxsRepAsGrossPro.setInsAvrevVal1(afterSaleArea.get(i).get平均单店售后保险衍生());
            jxsRepAsGrossPro.setGml3RateTax2(afterSaleArea.get(i).get售后三级毛利率());
            jxsRepAsGrossPro.setGml3AvrevVal1(afterSaleArea.get(i).get平均单店售后毛利Ⅲ());

            resultList.add(jxsRepAsGrossPro);
        }

        ArrayList<AfterSaleIndex> afterSaleAreaTotal = (ArrayList<AfterSaleIndex>) saleMap.get("售后_区域累计");
        for (int i = 0; i < afterSaleArea.size(); i++) {
            jxsRepAsGrossPro = new JxsRepAsGrossPro();
            jxsRepAsGrossPro.setId(getSecureRandom());//ID
            jxsRepAsGrossPro.setYearId(yearId);//年份
            jxsRepAsGrossPro.setQuarterId(quarterId);//季度
            jxsRepAsGrossPro.setRangeType(3);//rangeType
            jxsRepAsGrossPro.setStatisType(0);//累计or当前
            jxsRepAsGrossPro.setJxsRegionId(afterSaleAreaTotal.get(i).get区域ID());
            jxsRepAsGrossPro.setClaRateTax2(afterSaleAreaTotal.get(i).get索赔毛利贡献());
            jxsRepAsGrossPro.setClaAvrevVal1(afterSaleAreaTotal.get(i).get平均单店索赔贡献());
            jxsRepAsGrossPro.setClaAvrevVal2(afterSaleAreaTotal.get(i).get平均单车索赔贡献());
            jxsRepAsGrossPro.setUkRateTax2(afterSaleAreaTotal.get(i).get保养毛利贡献());
            jxsRepAsGrossPro.setUkAvrevVal1(afterSaleAreaTotal.get(i).get平均单店保养贡献());
            jxsRepAsGrossPro.setUkAvrevVal2(afterSaleAreaTotal.get(i).get平均单车保养贡献());
            jxsRepAsGrossPro.setAcvRateTax2(afterSaleAreaTotal.get(i).get事故车毛利贡献());
            jxsRepAsGrossPro.setAcvAvrevVal1(afterSaleAreaTotal.get(i).get平均单店事故车贡献());
            jxsRepAsGrossPro.setAcvAvrevVal2(afterSaleAreaTotal.get(i).get平均单车事故车贡献());
            jxsRepAsGrossPro.setSpRateTax2(afterSaleAreaTotal.get(i).get自费毛利贡献());
            jxsRepAsGrossPro.setSpAvrevVal1(afterSaleAreaTotal.get(i).get平均单店自费贡献());
            jxsRepAsGrossPro.setSpAvrevVal2(afterSaleAreaTotal.get(i).get平均单车自费贡献());
            jxsRepAsGrossPro.setGml1RateTax2(afterSaleAreaTotal.get(i).get售后毛利Ⅰ());
            jxsRepAsGrossPro.setGml1AvrevVal1(afterSaleAreaTotal.get(i).get平均单店售后毛利Ⅰ());
            jxsRepAsGrossPro.setGml1AvrevVal2(afterSaleAreaTotal.get(i).get平均单车售后毛利Ⅰ());
            jxsRepAsGrossPro.setRpReRateTax2(afterSaleAreaTotal.get(i).get备件返利贡献());
            jxsRepAsGrossPro.setRpReAvrevVal1(afterSaleAreaTotal.get(i).get平均单店售后返利());
            jxsRepAsGrossPro.setRpReAvrevVal2(afterSaleAreaTotal.get(i).get平均单车售后返利());
            jxsRepAsGrossPro.setGml2RateTax2(afterSaleAreaTotal.get(i).get售后毛利Ⅱ());
            jxsRepAsGrossPro.setGml2AvrevVal1(afterSaleAreaTotal.get(i).get平均单店售后毛利Ⅱ());
            jxsRepAsGrossPro.setGml2AvrevVal2(afterSaleAreaTotal.get(i).get平均单车售后毛利Ⅱ());
            jxsRepAsGrossPro.setRpRateTax2(afterSaleAreaTotal.get(i).get售后精品备件衍生贡献());
            jxsRepAsGrossPro.setRpAvrevVal1(afterSaleAreaTotal.get(i).get平均单店售后精品备件衍生());
            jxsRepAsGrossPro.setRpAvrevVal2(afterSaleAreaTotal.get(i).get平均单车售后精品备件衍生());
            jxsRepAsGrossPro.setInsRateTax2(afterSaleAreaTotal.get(i).get售后保险衍生贡献());
            jxsRepAsGrossPro.setInsAvrevVal1(afterSaleAreaTotal.get(i).get平均单店售后保险衍生());
            jxsRepAsGrossPro.setInsAvrevVal2(afterSaleAreaTotal.get(i).get平均单车售后保险衍生());
            jxsRepAsGrossPro.setGml3RateTax2(afterSaleAreaTotal.get(i).get售后三级毛利率());
            jxsRepAsGrossPro.setGml3AvrevVal1(afterSaleAreaTotal.get(i).get平均单店售后毛利Ⅲ());
            jxsRepAsGrossPro.setGml3AvrevVal2(afterSaleAreaTotal.get(i).get平均单车售后毛利Ⅲ());

            resultList.add(jxsRepAsGrossPro);
        }

        //经销商
        ArrayList<AfterSaleIndex> afterSaleDealer = (ArrayList<AfterSaleIndex>) saleMap.get("售后_经销商");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepAsGrossPro = new JxsRepAsGrossPro();
            jxsRepAsGrossPro.setId(getSecureRandom());//ID
            jxsRepAsGrossPro.setYearId(yearId);//年份
            jxsRepAsGrossPro.setQuarterId(quarterId);//季度
            jxsRepAsGrossPro.setRangeType(0);//rangeType
            jxsRepAsGrossPro.setStatisType(1);//累计or当前
            jxsRepAsGrossPro.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepAsGrossPro.setClaRateTax2(afterSaleDealer.get(i).get索赔毛利贡献());
            jxsRepAsGrossPro.setClaAvrevVal1(afterSaleDealer.get(i).get平均单店索赔贡献());
            jxsRepAsGrossPro.setUkRateTax2(afterSaleDealer.get(i).get保养毛利贡献());
            jxsRepAsGrossPro.setUkAvrevVal1(afterSaleDealer.get(i).get平均单店保养贡献());
            jxsRepAsGrossPro.setAcvRateTax2(afterSaleDealer.get(i).get事故车毛利贡献());
            jxsRepAsGrossPro.setAcvAvrevVal1(afterSaleDealer.get(i).get平均单店事故车贡献());
            jxsRepAsGrossPro.setSpRateTax2(afterSaleDealer.get(i).get自费毛利贡献());
            jxsRepAsGrossPro.setSpAvrevVal1(afterSaleDealer.get(i).get平均单店自费贡献());
            jxsRepAsGrossPro.setGml1RateTax2(afterSaleDealer.get(i).get售后毛利Ⅰ());
            jxsRepAsGrossPro.setGml1AvrevVal1(afterSaleDealer.get(i).get平均单店售后毛利Ⅰ());
            jxsRepAsGrossPro.setRpReRateTax2(afterSaleDealer.get(i).get备件返利贡献());
            jxsRepAsGrossPro.setRpReAvrevVal1(afterSaleDealer.get(i).get平均单店售后返利());
            jxsRepAsGrossPro.setGml2RateTax2(afterSaleDealer.get(i).get售后毛利Ⅱ());
            jxsRepAsGrossPro.setGml2AvrevVal1(afterSaleDealer.get(i).get平均单店售后毛利Ⅱ());
            jxsRepAsGrossPro.setRpRateTax2(afterSaleDealer.get(i).get售后精品备件衍生贡献());
            jxsRepAsGrossPro.setRpAvrevVal1(afterSaleDealer.get(i).get平均单店售后精品备件衍生());
            jxsRepAsGrossPro.setInsRateTax2(afterSaleDealer.get(i).get售后保险衍生贡献());
            jxsRepAsGrossPro.setInsAvrevVal1(afterSaleDealer.get(i).get平均单店售后保险衍生());
            jxsRepAsGrossPro.setGml3RateTax2(afterSaleDealer.get(i).get售后三级毛利率());
            jxsRepAsGrossPro.setGml3AvrevVal1(afterSaleDealer.get(i).get平均单店售后毛利Ⅲ());

            resultList.add(jxsRepAsGrossPro);
        }

        ArrayList<AfterSaleIndex> afterSaleDealerTotal = (ArrayList<AfterSaleIndex>) saleMap.get("售后_经销商累计");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepAsGrossPro = new JxsRepAsGrossPro();
            jxsRepAsGrossPro.setId(getSecureRandom());//ID
            jxsRepAsGrossPro.setYearId(yearId);//年份
            jxsRepAsGrossPro.setQuarterId(quarterId);//季度
            jxsRepAsGrossPro.setRangeType(0);//rangeType
            jxsRepAsGrossPro.setStatisType(0);//累计or当前
            jxsRepAsGrossPro.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepAsGrossPro.setClaRateTax2(afterSaleDealerTotal.get(i).get索赔毛利贡献());
            jxsRepAsGrossPro.setClaAvrevVal1(afterSaleDealerTotal.get(i).get平均单店索赔贡献());
            jxsRepAsGrossPro.setClaAvrevVal2(afterSaleDealerTotal.get(i).get平均单车索赔贡献());
            jxsRepAsGrossPro.setUkRateTax2(afterSaleDealerTotal.get(i).get保养毛利贡献());
            jxsRepAsGrossPro.setUkAvrevVal1(afterSaleDealerTotal.get(i).get平均单店保养贡献());
            jxsRepAsGrossPro.setUkAvrevVal2(afterSaleDealerTotal.get(i).get平均单车保养贡献());
            jxsRepAsGrossPro.setAcvRateTax2(afterSaleDealerTotal.get(i).get事故车毛利贡献());
            jxsRepAsGrossPro.setAcvAvrevVal1(afterSaleDealerTotal.get(i).get平均单店事故车贡献());
            jxsRepAsGrossPro.setAcvAvrevVal2(afterSaleDealerTotal.get(i).get平均单车事故车贡献());
            jxsRepAsGrossPro.setSpRateTax2(afterSaleDealerTotal.get(i).get自费毛利贡献());
            jxsRepAsGrossPro.setSpAvrevVal1(afterSaleDealerTotal.get(i).get平均单店自费贡献());
            jxsRepAsGrossPro.setSpAvrevVal2(afterSaleDealerTotal.get(i).get平均单车自费贡献());
            jxsRepAsGrossPro.setGml1RateTax2(afterSaleDealerTotal.get(i).get售后毛利Ⅰ());
            jxsRepAsGrossPro.setGml1AvrevVal1(afterSaleDealerTotal.get(i).get平均单店售后毛利Ⅰ());
            jxsRepAsGrossPro.setGml1AvrevVal2(afterSaleDealerTotal.get(i).get平均单车售后毛利Ⅰ());
            jxsRepAsGrossPro.setRpReRateTax2(afterSaleDealerTotal.get(i).get备件返利贡献());
            jxsRepAsGrossPro.setRpReAvrevVal1(afterSaleDealerTotal.get(i).get平均单店售后返利());
            jxsRepAsGrossPro.setRpReAvrevVal2(afterSaleDealerTotal.get(i).get平均单车售后返利());
            jxsRepAsGrossPro.setGml2RateTax2(afterSaleDealerTotal.get(i).get售后毛利Ⅱ());
            jxsRepAsGrossPro.setGml2AvrevVal1(afterSaleDealerTotal.get(i).get平均单店售后毛利Ⅱ());
            jxsRepAsGrossPro.setGml2AvrevVal2(afterSaleDealerTotal.get(i).get平均单车售后毛利Ⅱ());
            jxsRepAsGrossPro.setRpRateTax2(afterSaleDealerTotal.get(i).get售后精品备件衍生贡献());
            jxsRepAsGrossPro.setRpAvrevVal1(afterSaleDealerTotal.get(i).get平均单店售后精品备件衍生());
            jxsRepAsGrossPro.setRpAvrevVal2(afterSaleDealerTotal.get(i).get平均单车售后精品备件衍生());
            jxsRepAsGrossPro.setInsRateTax2(afterSaleDealerTotal.get(i).get售后保险衍生贡献());
            jxsRepAsGrossPro.setInsAvrevVal1(afterSaleDealerTotal.get(i).get平均单店售后保险衍生());
            jxsRepAsGrossPro.setInsAvrevVal2(afterSaleDealerTotal.get(i).get平均单车售后保险衍生());
            jxsRepAsGrossPro.setGml3RateTax2(afterSaleDealerTotal.get(i).get售后三级毛利率());
            jxsRepAsGrossPro.setGml3AvrevVal1(afterSaleDealerTotal.get(i).get平均单店售后毛利Ⅲ());
            jxsRepAsGrossPro.setGml3AvrevVal2(afterSaleDealerTotal.get(i).get平均单车售后毛利Ⅲ());

            resultList.add(jxsRepAsGrossPro);
        }

        try {
            databaseDao.deleteJxsRepAsGrossPro(yearId, quarterId);
            databaseDao.insertJxsRepAsGrossPro(resultList);

        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }


    }

    @Override
    public void handleJxsRepAsOutputGross(String yearId, String quarterId, List<DealerForm> dealerList, Map<String, Object> carMap,
                                          Map<String, Object> usedMap, Map<String, Object> saleMap, Map<String, Object> globalMap) throws NoSuchAlgorithmException {

        List<JxsRepAsOutputGross> resultList = new ArrayList<>();
        ObjectMapper objectMapper = new ObjectMapper();
        JxsRepAsOutputGross jxsRepAsOutputGross;

        //全国
        jxsRepAsOutputGross = new JxsRepAsOutputGross();
        jxsRepAsOutputGross.setId(getSecureRandom());//ID
        jxsRepAsOutputGross.setYearId(yearId);//年份
        jxsRepAsOutputGross.setQuarterId(quarterId);//季度
        jxsRepAsOutputGross.setRangeType(4);//rangeType
        jxsRepAsOutputGross.setStatisType(1);//累计or当前
        jxsRepAsOutputGross.setAsOutput(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get平均单店售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAsOutputGross.setGmlRateTax(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get售后一级毛利率());

        resultList.add(jxsRepAsOutputGross);

        //全国
        jxsRepAsOutputGross = new JxsRepAsOutputGross();
        jxsRepAsOutputGross.setId(getSecureRandom());//ID
        jxsRepAsOutputGross.setYearId(yearId);//年份
        jxsRepAsOutputGross.setQuarterId(quarterId);//季度
        jxsRepAsOutputGross.setRangeType(4);//rangeType
        jxsRepAsOutputGross.setStatisType(0);//累计or当前
        jxsRepAsOutputGross.setAsOutput(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAsOutputGross.setGmlRateTax(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get售后一级毛利率());

        resultList.add(jxsRepAsOutputGross);

        //大区
        ArrayList<AfterSaleIndex> afterSaleArea = (ArrayList<AfterSaleIndex>) saleMap.get("售后_区域");
        for (int i = 0; i < afterSaleArea.size(); i++) {
            jxsRepAsOutputGross = new JxsRepAsOutputGross();
            jxsRepAsOutputGross.setId(getSecureRandom());//ID
            jxsRepAsOutputGross.setYearId(yearId);//年份
            jxsRepAsOutputGross.setQuarterId(quarterId);//季度
            jxsRepAsOutputGross.setRangeType(3);//rangeType
            jxsRepAsOutputGross.setStatisType(1);//累计or当前
            jxsRepAsOutputGross.setJxsRegionId(afterSaleArea.get(i).get区域ID());
            jxsRepAsOutputGross.setAsOutput(afterSaleArea.get(i).get平均单店售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsOutputGross.setGmlRateTax(afterSaleArea.get(i).get售后一级毛利率());

            resultList.add(jxsRepAsOutputGross);
        }

        //大区
        ArrayList<AfterSaleIndex> afterSaleAreaTotal = (ArrayList<AfterSaleIndex>) saleMap.get("售后_区域累计");
        for (int i = 0; i < afterSaleArea.size(); i++) {
            jxsRepAsOutputGross = new JxsRepAsOutputGross();
            jxsRepAsOutputGross.setId(getSecureRandom());//ID
            jxsRepAsOutputGross.setYearId(yearId);//年份
            jxsRepAsOutputGross.setQuarterId(quarterId);//季度
            jxsRepAsOutputGross.setRangeType(3);//rangeType
            jxsRepAsOutputGross.setStatisType(0);//累计or当前
            jxsRepAsOutputGross.setJxsRegionId(afterSaleArea.get(i).get区域ID());
            jxsRepAsOutputGross.setAsOutput(afterSaleAreaTotal.get(i).get平均单店售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsOutputGross.setGmlRateTax(afterSaleAreaTotal.get(i).get售后一级毛利率());

            resultList.add(jxsRepAsOutputGross);
        }

        //经销商
        ArrayList<AfterSaleIndex> afterSaleDealer = (ArrayList<AfterSaleIndex>) saleMap.get("售后_经销商");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepAsOutputGross = new JxsRepAsOutputGross();
            jxsRepAsOutputGross.setId(getSecureRandom());//ID
            jxsRepAsOutputGross.setYearId(yearId);//年份
            jxsRepAsOutputGross.setQuarterId(quarterId);//季度
            jxsRepAsOutputGross.setRangeType(0);//rangeType
            jxsRepAsOutputGross.setStatisType(1);//累计or当前
            jxsRepAsOutputGross.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepAsOutputGross.setAsOutput(afterSaleDealer.get(i).get平均单店售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsOutputGross.setGmlRateTax(afterSaleDealer.get(i).get售后一级毛利率());

            resultList.add(jxsRepAsOutputGross);
        }

        //经销商
        ArrayList<AfterSaleIndex> afterSaleDealerTotal = (ArrayList<AfterSaleIndex>) saleMap.get("售后_经销商累计");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepAsOutputGross = new JxsRepAsOutputGross();
            jxsRepAsOutputGross.setId(getSecureRandom());//ID
            jxsRepAsOutputGross.setYearId(yearId);//年份
            jxsRepAsOutputGross.setQuarterId(quarterId);//季度
            jxsRepAsOutputGross.setRangeType(0);//rangeType
            jxsRepAsOutputGross.setStatisType(0);//累计or当前
            jxsRepAsOutputGross.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepAsOutputGross.setAsOutput(afterSaleDealerTotal.get(i).get平均单店售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsOutputGross.setGmlRateTax(afterSaleDealerTotal.get(i).get售后一级毛利率());

            resultList.add(jxsRepAsOutputGross);
        }

        try {
            databaseDao.deleteJxsRepAsOutputGross(yearId, quarterId);
            databaseDao.insertJxsRepAsOutputGross(resultList);


        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }


    }

    @Override
    public void handleJxsRepAsOutputGross19(String yearId, String quarterId, List<DealerForm> dealerList, Map<String, Object> carMap,
                                            Map<String, Object> usedMap, Map<String, Object> saleMap, Map<String, Object> globalMap) throws NoSuchAlgorithmException {

        List<JxsRepAsOutputGross19> resultList = new ArrayList<>();
        ObjectMapper objectMapper = new ObjectMapper();
        JxsRepAsOutputGross19 jxsRepAsOutputGross19;

        //全国
        jxsRepAsOutputGross19 = new JxsRepAsOutputGross19();
        jxsRepAsOutputGross19.setId(getSecureRandom());//ID
        jxsRepAsOutputGross19.setYearId(yearId);//年份
        jxsRepAsOutputGross19.setQuarterId(quarterId);//季度
        jxsRepAsOutputGross19.setRangeType(4);//rangeType
        jxsRepAsOutputGross19.setStatisType(1);//累计or当前
        jxsRepAsOutputGross19.setUnabsorbedCost(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get未被吸收的费用_平均单店().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAsOutputGross19.setAsAbsorptivity(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get售后吸收率());

        resultList.add(jxsRepAsOutputGross19);

        //全国
        jxsRepAsOutputGross19 = new JxsRepAsOutputGross19();
        jxsRepAsOutputGross19.setId(getSecureRandom());//ID
        jxsRepAsOutputGross19.setYearId(yearId);//年份
        jxsRepAsOutputGross19.setQuarterId(quarterId);//季度
        jxsRepAsOutputGross19.setRangeType(4);//rangeType
        jxsRepAsOutputGross19.setStatisType(0);//累计or当前
        jxsRepAsOutputGross19.setUnabsorbedCost(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get未被吸收的费用_平均单店().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAsOutputGross19.setAsAbsorptivity(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get售后吸收率());

        resultList.add(jxsRepAsOutputGross19);

        //大区
        ArrayList<AfterSaleIndex> afterSaleArea = (ArrayList<AfterSaleIndex>) saleMap.get("售后_区域");
        for (int i = 0; i < afterSaleArea.size(); i++) {
            jxsRepAsOutputGross19 = new JxsRepAsOutputGross19();
            jxsRepAsOutputGross19.setId(getSecureRandom());//ID
            jxsRepAsOutputGross19.setYearId(yearId);//年份
            jxsRepAsOutputGross19.setQuarterId(quarterId);//季度
            jxsRepAsOutputGross19.setRangeType(3);//rangeType
            jxsRepAsOutputGross19.setStatisType(1);//累计or当前
            jxsRepAsOutputGross19.setJxsRegionId(afterSaleArea.get(i).get区域ID());
            jxsRepAsOutputGross19.setUnabsorbedCost(afterSaleArea.get(i).get未被吸收的费用_平均单店().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsOutputGross19.setAsAbsorptivity(afterSaleArea.get(i).get售后吸收率());

            resultList.add(jxsRepAsOutputGross19);
        }

        //大区
        ArrayList<AfterSaleIndex> afterSaleAreaTotal = (ArrayList<AfterSaleIndex>) saleMap.get("售后_区域累计");
        for (int i = 0; i < afterSaleArea.size(); i++) {
            jxsRepAsOutputGross19 = new JxsRepAsOutputGross19();
            jxsRepAsOutputGross19.setId(getSecureRandom());//ID
            jxsRepAsOutputGross19.setYearId(yearId);//年份
            jxsRepAsOutputGross19.setQuarterId(quarterId);//季度
            jxsRepAsOutputGross19.setRangeType(3);//rangeType
            jxsRepAsOutputGross19.setStatisType(0);//累计or当前
            jxsRepAsOutputGross19.setJxsRegionId(afterSaleAreaTotal.get(i).get区域ID());
            jxsRepAsOutputGross19.setUnabsorbedCost(afterSaleAreaTotal.get(i).get未被吸收的费用_平均单店().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsOutputGross19.setAsAbsorptivity(afterSaleAreaTotal.get(i).get售后吸收率());

            resultList.add(jxsRepAsOutputGross19);
        }

        //经销商
        ArrayList<AfterSaleIndex> afterSaleDealer = (ArrayList<AfterSaleIndex>) saleMap.get("售后_经销商");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepAsOutputGross19 = new JxsRepAsOutputGross19();
            jxsRepAsOutputGross19.setId(getSecureRandom());//ID
            jxsRepAsOutputGross19.setYearId(yearId);//年份
            jxsRepAsOutputGross19.setQuarterId(quarterId);//季度
            jxsRepAsOutputGross19.setRangeType(0);//rangeType
            jxsRepAsOutputGross19.setStatisType(1);//累计or当前
            jxsRepAsOutputGross19.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepAsOutputGross19.setUnabsorbedCost(afterSaleDealer.get(i).get未被吸收的费用_平均单店().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsOutputGross19.setAsAbsorptivity(afterSaleDealer.get(i).get售后吸收率());

            resultList.add(jxsRepAsOutputGross19);
        }

        //经销商
        ArrayList<AfterSaleIndex> afterSaleDealerTotal = (ArrayList<AfterSaleIndex>) saleMap.get("售后_经销商累计");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepAsOutputGross19 = new JxsRepAsOutputGross19();
            jxsRepAsOutputGross19.setId(getSecureRandom());//ID
            jxsRepAsOutputGross19.setYearId(yearId);//年份
            jxsRepAsOutputGross19.setQuarterId(quarterId);//季度
            jxsRepAsOutputGross19.setRangeType(0);//rangeType
            jxsRepAsOutputGross19.setStatisType(0);//累计or当前
            jxsRepAsOutputGross19.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepAsOutputGross19.setUnabsorbedCost(afterSaleDealerTotal.get(i).get未被吸收的费用_平均单店().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsOutputGross19.setAsAbsorptivity(afterSaleDealerTotal.get(i).get售后吸收率());

            resultList.add(jxsRepAsOutputGross19);
        }
        try {
            databaseDao.deleteJxsRepAsOutputGross19(yearId, quarterId);
            databaseDao.insertJxsRepAsOutputGross19(resultList);


        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }


    }

    @Override
    public void handleJxsRepAsOutputNum(String yearId, String quarterId, List<DealerForm> dealerList, Map<String, Object> carMap,
                                        Map<String, Object> usedMap, Map<String, Object> saleMap, Map<String, Object> globalMap) throws NoSuchAlgorithmException {

        List<JxsRepAsOutputNum> resultList = new ArrayList<>();
        ObjectMapper objectMapper = new ObjectMapper();
        JxsRepAsOutputNum jxsRepAsOutputNum;

        //全国
        jxsRepAsOutputNum = new JxsRepAsOutputNum();
        jxsRepAsOutputNum.setId(getSecureRandom());//ID
        jxsRepAsOutputNum.setYearId(yearId);//年份
        jxsRepAsOutputNum.setQuarterId(quarterId);//季度
        jxsRepAsOutputNum.setRangeType(4);//rangeType
        jxsRepAsOutputNum.setStatisType(1);//累计or当前
        jxsRepAsOutputNum.setClaOutput(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get平均单店索赔售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAsOutputNum.setClaNum(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get平均单店索赔进厂台次());
        jxsRepAsOutputNum.setFukOutput(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get平均单店保养售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAsOutputNum.setFukNum(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get平均单店保养进厂台次());
        jxsRepAsOutputNum.setAcvOutput(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get平均单店事故车售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAsOutputNum.setAcvNum(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get平均单店事故车进厂台次());
        jxsRepAsOutputNum.setUkOutput(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get平均单店自费售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAsOutputNum.setUkNum(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get平均单店自费进厂台次());
        jxsRepAsOutputNum.setTotalOutput(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get平均单店售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAsOutputNum.setTotalNum(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get售后进厂台次平均单店());

        resultList.add(jxsRepAsOutputNum);

        //全国
        jxsRepAsOutputNum = new JxsRepAsOutputNum();
        jxsRepAsOutputNum.setId(getSecureRandom());//ID
        jxsRepAsOutputNum.setYearId(yearId);//年份
        jxsRepAsOutputNum.setQuarterId(quarterId);//季度
        jxsRepAsOutputNum.setRangeType(4);//rangeType
        jxsRepAsOutputNum.setStatisType(0);//累计or当前
        jxsRepAsOutputNum.setClaOutput(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店索赔售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAsOutputNum.setClaNum(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店索赔进厂台次());
        jxsRepAsOutputNum.setFukOutput(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店保养售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAsOutputNum.setFukNum(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店保养进厂台次());
        jxsRepAsOutputNum.setAcvOutput(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店事故车售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAsOutputNum.setAcvNum(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店事故车进厂台次());
        jxsRepAsOutputNum.setUkOutput(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店自费售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAsOutputNum.setUkNum(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店自费进厂台次());
        jxsRepAsOutputNum.setTotalOutput(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单店售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
        jxsRepAsOutputNum.setTotalNum(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get售后进厂台次平均单店());

        resultList.add(jxsRepAsOutputNum);

        //大区
        ArrayList<AfterSaleIndex> afterSaleArea = (ArrayList<AfterSaleIndex>) saleMap.get("售后_区域");
        for (int i = 0; i < afterSaleArea.size(); i++) {
            jxsRepAsOutputNum = new JxsRepAsOutputNum();
            jxsRepAsOutputNum.setId(getSecureRandom());//ID
            jxsRepAsOutputNum.setYearId(yearId);//年份
            jxsRepAsOutputNum.setQuarterId(quarterId);//季度
            jxsRepAsOutputNum.setRangeType(3);//rangeType
            jxsRepAsOutputNum.setStatisType(1);//累计or当前
            jxsRepAsOutputNum.setJxsRegionId(afterSaleArea.get(i).get区域ID());
            jxsRepAsOutputNum.setClaOutput(afterSaleArea.get(i).get平均单店索赔售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsOutputNum.setClaNum(afterSaleArea.get(i).get平均单店索赔进厂台次());
            jxsRepAsOutputNum.setFukOutput(afterSaleArea.get(i).get平均单店保养售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsOutputNum.setFukNum(afterSaleArea.get(i).get平均单店保养进厂台次());
            jxsRepAsOutputNum.setAcvOutput(afterSaleArea.get(i).get平均单店事故车售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsOutputNum.setAcvNum(afterSaleArea.get(i).get平均单店事故车进厂台次());
            jxsRepAsOutputNum.setUkOutput(afterSaleArea.get(i).get平均单店自费售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsOutputNum.setUkNum(afterSaleArea.get(i).get平均单店自费进厂台次());
            jxsRepAsOutputNum.setTotalOutput(afterSaleArea.get(i).get平均单店售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsOutputNum.setTotalNum(afterSaleArea.get(i).get售后进厂台次平均单店());

            resultList.add(jxsRepAsOutputNum);
        }

        //大区
        ArrayList<AfterSaleIndex> afterSaleAreaTotal = (ArrayList<AfterSaleIndex>) saleMap.get("售后_区域累计");
        for (int i = 0; i < afterSaleArea.size(); i++) {
            jxsRepAsOutputNum = new JxsRepAsOutputNum();
            jxsRepAsOutputNum.setId(getSecureRandom());//ID
            jxsRepAsOutputNum.setYearId(yearId);//年份
            jxsRepAsOutputNum.setQuarterId(quarterId);//季度
            jxsRepAsOutputNum.setRangeType(3);//rangeType
            jxsRepAsOutputNum.setStatisType(0);//累计or当前
            jxsRepAsOutputNum.setJxsRegionId(afterSaleAreaTotal.get(i).get区域ID());
            jxsRepAsOutputNum.setClaOutput(afterSaleAreaTotal.get(i).get平均单店索赔售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsOutputNum.setClaNum(afterSaleAreaTotal.get(i).get平均单店索赔进厂台次());
            jxsRepAsOutputNum.setFukOutput(afterSaleAreaTotal.get(i).get平均单店保养售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsOutputNum.setFukNum(afterSaleAreaTotal.get(i).get平均单店保养进厂台次());
            jxsRepAsOutputNum.setAcvOutput(afterSaleAreaTotal.get(i).get平均单店事故车售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsOutputNum.setAcvNum(afterSaleAreaTotal.get(i).get平均单店事故车进厂台次());
            jxsRepAsOutputNum.setUkOutput(afterSaleAreaTotal.get(i).get平均单店自费售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsOutputNum.setUkNum(afterSaleAreaTotal.get(i).get平均单店自费进厂台次());
            jxsRepAsOutputNum.setTotalOutput(afterSaleAreaTotal.get(i).get平均单店售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsOutputNum.setTotalNum(afterSaleAreaTotal.get(i).get售后进厂台次平均单店());

            resultList.add(jxsRepAsOutputNum);
        }

        //经销商
        ArrayList<AfterSaleIndex> afterSaleDealer = (ArrayList<AfterSaleIndex>) saleMap.get("售后_经销商");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepAsOutputNum = new JxsRepAsOutputNum();
            jxsRepAsOutputNum.setId(getSecureRandom());//ID
            jxsRepAsOutputNum.setYearId(yearId);//年份
            jxsRepAsOutputNum.setQuarterId(quarterId);//季度
            jxsRepAsOutputNum.setRangeType(0);//rangeType
            jxsRepAsOutputNum.setStatisType(1);//累计or当前
            jxsRepAsOutputNum.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepAsOutputNum.setClaOutput(afterSaleDealer.get(i).get平均单店索赔售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsOutputNum.setClaNum(afterSaleDealer.get(i).get平均单店索赔进厂台次());
            jxsRepAsOutputNum.setFukOutput(afterSaleDealer.get(i).get平均单店保养售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsOutputNum.setFukNum(afterSaleDealer.get(i).get平均单店保养进厂台次());
            jxsRepAsOutputNum.setAcvOutput(afterSaleDealer.get(i).get平均单店事故车售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsOutputNum.setAcvNum(afterSaleDealer.get(i).get平均单店事故车进厂台次());
            jxsRepAsOutputNum.setUkOutput(afterSaleDealer.get(i).get平均单店自费售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsOutputNum.setUkNum(afterSaleDealer.get(i).get平均单店自费进厂台次());
            jxsRepAsOutputNum.setTotalOutput(afterSaleDealer.get(i).get平均单店售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsOutputNum.setTotalNum(afterSaleDealer.get(i).get售后进厂台次平均单店());

            resultList.add(jxsRepAsOutputNum);
        }

        //经销商
        ArrayList<AfterSaleIndex> afterSaleDealerTotal = (ArrayList<AfterSaleIndex>) saleMap.get("售后_经销商累计");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepAsOutputNum = new JxsRepAsOutputNum();
            jxsRepAsOutputNum.setId(getSecureRandom());//ID
            jxsRepAsOutputNum.setYearId(yearId);//年份
            jxsRepAsOutputNum.setQuarterId(quarterId);//季度
            jxsRepAsOutputNum.setRangeType(0);//rangeType
            jxsRepAsOutputNum.setStatisType(0);//累计or当前
            jxsRepAsOutputNum.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepAsOutputNum.setClaOutput(afterSaleDealerTotal.get(i).get平均单店索赔售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsOutputNum.setClaNum(afterSaleDealerTotal.get(i).get平均单店索赔进厂台次());
            jxsRepAsOutputNum.setFukOutput(afterSaleDealerTotal.get(i).get平均单店保养售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsOutputNum.setFukNum(afterSaleDealerTotal.get(i).get平均单店保养进厂台次());
            jxsRepAsOutputNum.setAcvOutput(afterSaleDealerTotal.get(i).get平均单店事故车售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsOutputNum.setAcvNum(afterSaleDealerTotal.get(i).get平均单店事故车进厂台次());
            jxsRepAsOutputNum.setUkOutput(afterSaleDealerTotal.get(i).get平均单店自费售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsOutputNum.setUkNum(afterSaleDealerTotal.get(i).get平均单店自费进厂台次());
            jxsRepAsOutputNum.setTotalOutput(afterSaleDealerTotal.get(i).get平均单店售后产值().divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_EVEN));
            jxsRepAsOutputNum.setTotalNum(afterSaleDealerTotal.get(i).get售后进厂台次平均单店());

            resultList.add(jxsRepAsOutputNum);
        }

        try {
            databaseDao.deleteJxsRepAsOutputNum(yearId, quarterId);
            databaseDao.insertJxsRepAsOutputNum(resultList);

        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }


    }

    @Override
    public void handleJxsRepAsOutputRateTax(String yearId, String quarterId, List<DealerForm> dealerList, Map<String, Object> carMap,
                                            Map<String, Object> usedMap, Map<String, Object> saleMap, Map<String, Object> globalMap) throws NoSuchAlgorithmException {

        List<JxsRepAsOutputRateTax> resultList = new ArrayList<>();
        ObjectMapper objectMapper = new ObjectMapper();
        JxsRepAsOutputRateTax jxsRepAsOutputRateTax;

        //全国
        jxsRepAsOutputRateTax = new JxsRepAsOutputRateTax();
        jxsRepAsOutputRateTax.setId(getSecureRandom());//ID
        jxsRepAsOutputRateTax.setYearId(yearId);//年份
        jxsRepAsOutputRateTax.setQuarterId(quarterId);//季度
        jxsRepAsOutputRateTax.setRangeType(4);//rangeType
        jxsRepAsOutputRateTax.setStatisType(1);//累计or当前
        jxsRepAsOutputRateTax.setClaOutput(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get平均单车索赔售后产值());
        jxsRepAsOutputRateTax.setClaRateTax(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get索赔一级毛利率());
        jxsRepAsOutputRateTax.setFukOutput(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get平均单车保养售后产值());
        jxsRepAsOutputRateTax.setFukRateTax(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get保养一级毛利率());
        jxsRepAsOutputRateTax.setAcvOutput(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get平均单车事故车售后产值());
        jxsRepAsOutputRateTax.setAcvRateTax(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get事故车一级毛利率());
        jxsRepAsOutputRateTax.setUkOutput(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get平均单车自费售后产值());
        jxsRepAsOutputRateTax.setUkRateTax(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get自费一级毛利率());
        jxsRepAsOutputRateTax.setTotalOutput(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get售后单车产值());
        jxsRepAsOutputRateTax.setTotalRateTax(objectMapper.convertValue(saleMap.get("售后_全国"), AfterSaleIndex.class).get售后一级毛利率());

        resultList.add(jxsRepAsOutputRateTax);

        //全国
        jxsRepAsOutputRateTax = new JxsRepAsOutputRateTax();
        jxsRepAsOutputRateTax.setId(getSecureRandom());//ID
        jxsRepAsOutputRateTax.setYearId(yearId);//年份
        jxsRepAsOutputRateTax.setQuarterId(quarterId);//季度
        jxsRepAsOutputRateTax.setRangeType(4);//rangeType
        jxsRepAsOutputRateTax.setStatisType(0);//累计or当前
        jxsRepAsOutputRateTax.setClaOutput(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单车索赔售后产值());
        jxsRepAsOutputRateTax.setClaRateTax(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get索赔一级毛利率());
        jxsRepAsOutputRateTax.setFukOutput(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单车保养售后产值());
        jxsRepAsOutputRateTax.setFukRateTax(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get保养一级毛利率());
        jxsRepAsOutputRateTax.setAcvOutput(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单车事故车售后产值());
        jxsRepAsOutputRateTax.setAcvRateTax(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get事故车一级毛利率());
        jxsRepAsOutputRateTax.setUkOutput(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get平均单车自费售后产值());
        jxsRepAsOutputRateTax.setUkRateTax(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get自费一级毛利率());
        jxsRepAsOutputRateTax.setTotalOutput(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get售后单车产值());
        jxsRepAsOutputRateTax.setTotalRateTax(objectMapper.convertValue(saleMap.get("售后_全国累计"), AfterSaleIndex.class).get售后一级毛利率());

        resultList.add(jxsRepAsOutputRateTax);

        //大区
        ArrayList<AfterSaleIndex> afterSaleArea = (ArrayList<AfterSaleIndex>) saleMap.get("售后_区域");
        for (int i = 0; i < afterSaleArea.size(); i++) {
            jxsRepAsOutputRateTax = new JxsRepAsOutputRateTax();
            jxsRepAsOutputRateTax.setId(getSecureRandom());//ID
            jxsRepAsOutputRateTax.setYearId(yearId);//年份
            jxsRepAsOutputRateTax.setQuarterId(quarterId);//季度
            jxsRepAsOutputRateTax.setRangeType(3);//rangeType
            jxsRepAsOutputRateTax.setStatisType(1);//累计or当前
            jxsRepAsOutputRateTax.setJxsRegionId(afterSaleArea.get(i).get区域ID());
            jxsRepAsOutputRateTax.setClaOutput(afterSaleArea.get(i).get平均单车索赔售后产值());
            jxsRepAsOutputRateTax.setClaRateTax(afterSaleArea.get(i).get索赔一级毛利率());
            jxsRepAsOutputRateTax.setFukOutput(afterSaleArea.get(i).get平均单车保养售后产值());
            jxsRepAsOutputRateTax.setFukRateTax(afterSaleArea.get(i).get保养一级毛利率());
            jxsRepAsOutputRateTax.setAcvOutput(afterSaleArea.get(i).get平均单车事故车售后产值());
            jxsRepAsOutputRateTax.setAcvRateTax(afterSaleArea.get(i).get事故车一级毛利率());
            jxsRepAsOutputRateTax.setUkOutput(afterSaleArea.get(i).get平均单车自费售后产值());
            jxsRepAsOutputRateTax.setUkRateTax(afterSaleArea.get(i).get自费一级毛利率());
            jxsRepAsOutputRateTax.setTotalOutput(afterSaleArea.get(i).get售后单车产值());
            jxsRepAsOutputRateTax.setTotalRateTax(afterSaleArea.get(i).get售后一级毛利率());

            resultList.add(jxsRepAsOutputRateTax);
        }

        //大区
        ArrayList<AfterSaleIndex> afterSaleAreaTotal = (ArrayList<AfterSaleIndex>) saleMap.get("售后_区域累计");
        for (int i = 0; i < afterSaleArea.size(); i++) {
            jxsRepAsOutputRateTax = new JxsRepAsOutputRateTax();
            jxsRepAsOutputRateTax.setId(getSecureRandom());//ID
            jxsRepAsOutputRateTax.setYearId(yearId);//年份
            jxsRepAsOutputRateTax.setQuarterId(quarterId);//季度
            jxsRepAsOutputRateTax.setRangeType(3);//rangeType
            jxsRepAsOutputRateTax.setStatisType(0);//累计or当前
            jxsRepAsOutputRateTax.setJxsRegionId(afterSaleAreaTotal.get(i).get区域ID());
            jxsRepAsOutputRateTax.setClaOutput(afterSaleAreaTotal.get(i).get平均单车索赔售后产值());
            jxsRepAsOutputRateTax.setClaRateTax(afterSaleAreaTotal.get(i).get索赔一级毛利率());
            jxsRepAsOutputRateTax.setFukOutput(afterSaleAreaTotal.get(i).get平均单车保养售后产值());
            jxsRepAsOutputRateTax.setFukRateTax(afterSaleAreaTotal.get(i).get保养一级毛利率());
            jxsRepAsOutputRateTax.setAcvOutput(afterSaleAreaTotal.get(i).get平均单车事故车售后产值());
            jxsRepAsOutputRateTax.setAcvRateTax(afterSaleAreaTotal.get(i).get事故车一级毛利率());
            jxsRepAsOutputRateTax.setUkOutput(afterSaleAreaTotal.get(i).get平均单车自费售后产值());
            jxsRepAsOutputRateTax.setUkRateTax(afterSaleAreaTotal.get(i).get自费一级毛利率());
            jxsRepAsOutputRateTax.setTotalOutput(afterSaleAreaTotal.get(i).get售后单车产值());
            jxsRepAsOutputRateTax.setTotalRateTax(afterSaleAreaTotal.get(i).get售后一级毛利率());

            resultList.add(jxsRepAsOutputRateTax);
        }

        //经销商
        ArrayList<AfterSaleIndex> afterSaleDealer = (ArrayList<AfterSaleIndex>) saleMap.get("售后_经销商");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepAsOutputRateTax = new JxsRepAsOutputRateTax();
            jxsRepAsOutputRateTax.setId(getSecureRandom());//ID
            jxsRepAsOutputRateTax.setYearId(yearId);//年份
            jxsRepAsOutputRateTax.setQuarterId(quarterId);//季度
            jxsRepAsOutputRateTax.setRangeType(0);//rangeType
            jxsRepAsOutputRateTax.setStatisType(1);//累计or当前
            jxsRepAsOutputRateTax.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepAsOutputRateTax.setClaOutput(afterSaleDealer.get(i).get平均单车索赔售后产值());
            jxsRepAsOutputRateTax.setClaRateTax(afterSaleDealer.get(i).get索赔一级毛利率());
            jxsRepAsOutputRateTax.setFukOutput(afterSaleDealer.get(i).get平均单车保养售后产值());
            jxsRepAsOutputRateTax.setFukRateTax(afterSaleDealer.get(i).get保养一级毛利率());
            jxsRepAsOutputRateTax.setAcvOutput(afterSaleDealer.get(i).get平均单车事故车售后产值());
            jxsRepAsOutputRateTax.setAcvRateTax(afterSaleDealer.get(i).get事故车一级毛利率());
            jxsRepAsOutputRateTax.setUkOutput(afterSaleDealer.get(i).get平均单车自费售后产值());
            jxsRepAsOutputRateTax.setUkRateTax(afterSaleDealer.get(i).get自费一级毛利率());
            jxsRepAsOutputRateTax.setTotalOutput(afterSaleDealer.get(i).get售后单车产值());
            jxsRepAsOutputRateTax.setTotalRateTax(afterSaleDealer.get(i).get售后一级毛利率());

            resultList.add(jxsRepAsOutputRateTax);
        }

        //经销商
        ArrayList<AfterSaleIndex> afterSaleDealerTotal = (ArrayList<AfterSaleIndex>) saleMap.get("售后_经销商累计");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepAsOutputRateTax = new JxsRepAsOutputRateTax();
            jxsRepAsOutputRateTax.setId(getSecureRandom());//ID
            jxsRepAsOutputRateTax.setYearId(yearId);//年份
            jxsRepAsOutputRateTax.setQuarterId(quarterId);//季度
            jxsRepAsOutputRateTax.setRangeType(0);//rangeType
            jxsRepAsOutputRateTax.setStatisType(1);//累计or当前
            jxsRepAsOutputRateTax.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepAsOutputRateTax.setClaOutput(afterSaleDealerTotal.get(i).get平均单车索赔售后产值());
            jxsRepAsOutputRateTax.setClaRateTax(afterSaleDealerTotal.get(i).get索赔一级毛利率());
            jxsRepAsOutputRateTax.setFukOutput(afterSaleDealerTotal.get(i).get平均单车保养售后产值());
            jxsRepAsOutputRateTax.setFukRateTax(afterSaleDealerTotal.get(i).get保养一级毛利率());
            jxsRepAsOutputRateTax.setAcvOutput(afterSaleDealerTotal.get(i).get平均单车事故车售后产值());
            jxsRepAsOutputRateTax.setAcvRateTax(afterSaleDealerTotal.get(i).get事故车一级毛利率());
            jxsRepAsOutputRateTax.setUkOutput(afterSaleDealerTotal.get(i).get平均单车自费售后产值());
            jxsRepAsOutputRateTax.setUkRateTax(afterSaleDealerTotal.get(i).get自费一级毛利率());
            jxsRepAsOutputRateTax.setTotalOutput(afterSaleDealerTotal.get(i).get售后单车产值());
            jxsRepAsOutputRateTax.setTotalRateTax(afterSaleDealerTotal.get(i).get售后一级毛利率());

            resultList.add(jxsRepAsOutputRateTax);
        }

        try {
            databaseDao.deleteJxsRepAsOutputRateTax(yearId, quarterId);
            databaseDao.insertJxsRepAsOutputRateTax(resultList);

        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }

    }

    @Override
    public void handleJxsRepUcTotalInfo(String yearId, String quarterId, List<DealerForm> dealerList, Map<String, Object> carMap,
                                        Map<String, Object> usedMap, Map<String, Object> saleMap, Map<String, Object> globalMap) {

        List<JxsRepUcTotalInfo> resultList = new ArrayList<>();
        ObjectMapper objectMapper = new ObjectMapper();
        JxsRepUcTotalInfo jxsRepUcTotalInfo;

        //全国
        jxsRepUcTotalInfo = new JxsRepUcTotalInfo();
        jxsRepUcTotalInfo.setId(getUUID());//ID
        jxsRepUcTotalInfo.setYearId(yearId);//年份
        jxsRepUcTotalInfo.setQuarterId(quarterId);//季度
        jxsRepUcTotalInfo.setRangeType(4);//rangeType
        jxsRepUcTotalInfo.setSaleNum(objectMapper.convertValue(usedMap.get("二手车_全国"), UsedIndex.class).get二手车销售台次());
        jxsRepUcTotalInfo.setRevenueTotal(objectMapper.convertValue(usedMap.get("二手车_全国"), UsedIndex.class).get二手车销售收入());

        resultList.add(jxsRepUcTotalInfo);

        //大区
        ArrayList<UsedIndex> usedArea = (ArrayList<UsedIndex>) usedMap.get("二手车_区域");
        for (int i = 0; i < usedArea.size(); i++) {
            jxsRepUcTotalInfo = new JxsRepUcTotalInfo();
            jxsRepUcTotalInfo.setId(getUUID());//ID
            jxsRepUcTotalInfo.setYearId(yearId);//年份
            jxsRepUcTotalInfo.setQuarterId(quarterId);//季度
            jxsRepUcTotalInfo.setRangeType(3);//rangeType
            jxsRepUcTotalInfo.setJxsRegionId(usedArea.get(i).get区域ID());
            jxsRepUcTotalInfo.setSaleNum(usedArea.get(i).get二手车销售台次());
            jxsRepUcTotalInfo.setRevenueTotal(usedArea.get(i).get二手车销售收入());

            resultList.add(jxsRepUcTotalInfo);
        }

        //经销商
        ArrayList<UsedIndex> usedDealer = (ArrayList<UsedIndex>) usedMap.get("二手车_经销商");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepUcTotalInfo = new JxsRepUcTotalInfo();
            jxsRepUcTotalInfo.setId(getUUID());//ID
            jxsRepUcTotalInfo.setYearId(yearId);//年份
            jxsRepUcTotalInfo.setQuarterId(quarterId);//季度
            jxsRepUcTotalInfo.setRangeType(0);//rangeType
            jxsRepUcTotalInfo.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepUcTotalInfo.setSaleNum(usedDealer.get(i).get二手车销售台次());
            jxsRepUcTotalInfo.setRevenueTotal(usedDealer.get(i).get二手车销售收入());

            resultList.add(jxsRepUcTotalInfo);
        }

        try {
            databaseDao.deleteJxsRepUcTotalInfo(yearId, quarterId);
            databaseDao.insertJxsRepUcTotalInfo(resultList);

        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }


    }

    @Override
    public void handleJxsRepUcRevenueGross(String yearId, String quarterId, List<DealerForm> dealerList, Map<String, Object> carMap,
                                           Map<String, Object> usedMap, Map<String, Object> saleMap, Map<String, Object> globalMap) {

        List<JxsRepUcRevenueGross> resultList = new ArrayList<>();
        ObjectMapper objectMapper = new ObjectMapper();
        JxsRepUcRevenueGross jxsRepUcRevenueGross;

        //全国
        jxsRepUcRevenueGross = new JxsRepUcRevenueGross();
        jxsRepUcRevenueGross.setId(getUUID());//ID
        jxsRepUcRevenueGross.setYearId(yearId);//年份
        jxsRepUcRevenueGross.setQuarterId(quarterId);//季度
        jxsRepUcRevenueGross.setRangeType(4);//rangeType
        jxsRepUcRevenueGross.setStatisType(1);//当前季度
        jxsRepUcRevenueGross.setSdIncome(objectMapper.convertValue(usedMap.get("二手车_全国"), UsedIndex.class).get二手车平均单店收入());
        jxsRepUcRevenueGross.setGml2RateTax(objectMapper.convertValue(usedMap.get("二手车_全国"), UsedIndex.class).get二手车二级毛利率());
        jxsRepUcRevenueGross.setScIncome(objectMapper.convertValue(usedMap.get("二手车_全国"), UsedIndex.class).get平均单车收入());

        resultList.add(jxsRepUcRevenueGross);

        //全国
        jxsRepUcRevenueGross = new JxsRepUcRevenueGross();
        jxsRepUcRevenueGross.setId(getUUID());//ID
        jxsRepUcRevenueGross.setYearId(yearId);//年份
        jxsRepUcRevenueGross.setQuarterId(quarterId);//季度
        jxsRepUcRevenueGross.setRangeType(4);//rangeType
        jxsRepUcRevenueGross.setStatisType(0);//累计
        jxsRepUcRevenueGross.setSdIncome(objectMapper.convertValue(usedMap.get("二手车_全国累计"), UsedIndex.class).get二手车平均单店收入());
        jxsRepUcRevenueGross.setGml2RateTax(objectMapper.convertValue(usedMap.get("二手车_全国累计"), UsedIndex.class).get二手车二级毛利率());
        jxsRepUcRevenueGross.setScIncome(objectMapper.convertValue(usedMap.get("二手车_全国累计"), UsedIndex.class).get平均单车收入());

        resultList.add(jxsRepUcRevenueGross);

        //大区
        ArrayList<UsedIndex> usedArea = (ArrayList<UsedIndex>) usedMap.get("二手车_区域");
        for (int i = 0; i < usedArea.size(); i++) {
            jxsRepUcRevenueGross = new JxsRepUcRevenueGross();
            jxsRepUcRevenueGross.setId(getUUID());//ID
            jxsRepUcRevenueGross.setYearId(yearId);//年份
            jxsRepUcRevenueGross.setQuarterId(quarterId);//季度
            jxsRepUcRevenueGross.setRangeType(3);//rangeType
            jxsRepUcRevenueGross.setStatisType(1);//当前季度
            jxsRepUcRevenueGross.setJxsRegionId(usedArea.get(i).get区域ID());
            jxsRepUcRevenueGross.setSdIncome(usedArea.get(i).get二手车平均单店收入());
            jxsRepUcRevenueGross.setGml2RateTax(usedArea.get(i).get二手车二级毛利率());
            jxsRepUcRevenueGross.setScIncome(usedArea.get(i).get平均单车收入());

            resultList.add(jxsRepUcRevenueGross);
        }

        //大区
        ArrayList<UsedIndex> usedAreaTotal = (ArrayList<UsedIndex>) usedMap.get("二手车_区域累计");
        for (int i = 0; i < usedArea.size(); i++) {
            jxsRepUcRevenueGross = new JxsRepUcRevenueGross();
            jxsRepUcRevenueGross.setId(getUUID());//ID
            jxsRepUcRevenueGross.setYearId(yearId);//年份
            jxsRepUcRevenueGross.setQuarterId(quarterId);//季度
            jxsRepUcRevenueGross.setRangeType(3);//rangeType
            jxsRepUcRevenueGross.setStatisType(0);//累计
            jxsRepUcRevenueGross.setJxsRegionId(usedAreaTotal.get(i).get区域ID());
            jxsRepUcRevenueGross.setSdIncome(usedAreaTotal.get(i).get二手车平均单店收入());
            jxsRepUcRevenueGross.setGml2RateTax(usedAreaTotal.get(i).get二手车二级毛利率());
            jxsRepUcRevenueGross.setScIncome(usedAreaTotal.get(i).get平均单车收入());

            resultList.add(jxsRepUcRevenueGross);
        }

        //经销商
        ArrayList<UsedIndex> usedDealer = (ArrayList<UsedIndex>) usedMap.get("二手车_经销商");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepUcRevenueGross = new JxsRepUcRevenueGross();
            jxsRepUcRevenueGross.setId(getUUID());//ID
            jxsRepUcRevenueGross.setYearId(yearId);//年份
            jxsRepUcRevenueGross.setQuarterId(quarterId);//季度
            jxsRepUcRevenueGross.setRangeType(0);//rangeType
            jxsRepUcRevenueGross.setStatisType(1);//当前季度
            jxsRepUcRevenueGross.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepUcRevenueGross.setSdIncome(usedDealer.get(i).get二手车平均单店收入());
            jxsRepUcRevenueGross.setGml2RateTax(usedDealer.get(i).get二手车二级毛利率());
            jxsRepUcRevenueGross.setScIncome(usedDealer.get(i).get平均单车收入());

            resultList.add(jxsRepUcRevenueGross);
        }

        //经销商
        ArrayList<UsedIndex> usedDealerTotal = (ArrayList<UsedIndex>) usedMap.get("二手车_经销商累计");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepUcRevenueGross = new JxsRepUcRevenueGross();
            jxsRepUcRevenueGross.setId(getUUID());//ID
            jxsRepUcRevenueGross.setYearId(yearId);//年份
            jxsRepUcRevenueGross.setQuarterId(quarterId);//季度
            jxsRepUcRevenueGross.setRangeType(0);//rangeType
            jxsRepUcRevenueGross.setStatisType(0);//累计
            jxsRepUcRevenueGross.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepUcRevenueGross.setSdIncome(usedDealerTotal.get(i).get二手车平均单店收入());
            jxsRepUcRevenueGross.setGml2RateTax(usedDealerTotal.get(i).get二手车二级毛利率());
            jxsRepUcRevenueGross.setScIncome(usedDealerTotal.get(i).get平均单车收入());

            resultList.add(jxsRepUcRevenueGross);
        }

        try {
            databaseDao.deleteJxsRepUcRevenueGross(yearId, quarterId);
            databaseDao.insertJxsRepUcRevenueGross(resultList);

        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }


    }

    @Override
    public void handleJxsRepProfitDistribute(String yearId, String quarterId, List<DealerForm> dealerList, Map<String, Object> carMap,
                                             Map<String, Object> usedMap, Map<String, Object> saleMap, Map<String, Object> globalMap) {

        List<JxsRepTotalInfo> totalList = new ArrayList<>();//累计
        List<JxsRepTotalInfo> currentList = new ArrayList<>();//累计
        JxsRepTotalInfo jxsRepTotalInfo;

        //经销商累计
        ArrayList<GlobalIndex> globalDealerTotal = (ArrayList<GlobalIndex>) globalMap.get("总体_经销商累计");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepTotalInfo = new JxsRepTotalInfo();
            jxsRepTotalInfo.setId(getUUID());//ID
            jxsRepTotalInfo.setYearId(yearId);//年份
            jxsRepTotalInfo.setQuarterId(quarterId);//季度
            jxsRepTotalInfo.setRangeType(0);//rangeType
            jxsRepTotalInfo.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepTotalInfo.setJxsRegionId(dealerList.get(i).getRegionName());
            jxsRepTotalInfo.setEbt(globalDealerTotal.get(i).getEBT本年累计税前净利润率());

            totalList.add(jxsRepTotalInfo);
        }

        //经销商当前季度
        ArrayList<GlobalIndex> globalDealer = (ArrayList<GlobalIndex>) globalMap.get("总体_经销商");
        for (int i = 0; i < dealerList.size(); i++) {
            jxsRepTotalInfo = new JxsRepTotalInfo();
            jxsRepTotalInfo.setId(getUUID());//ID
            jxsRepTotalInfo.setYearId(yearId);//年份
            jxsRepTotalInfo.setQuarterId(quarterId);//季度
            jxsRepTotalInfo.setRangeType(0);//rangeType
            jxsRepTotalInfo.setJxsDealerId(dealerList.get(i).getJxsDealerId());
            jxsRepTotalInfo.setJxsRegionId(dealerList.get(i).getRegionName());
            jxsRepTotalInfo.setEbt(globalDealer.get(i).get税前净利润率());

            currentList.add(jxsRepTotalInfo);
        }

        JxsRepProfitDistribute jxsRepProfitDistribute;

        List<JxsRepProfitDistribute> resultList = new ArrayList<>();

        List<BigDecimal> ebt = new ArrayList<>();
        currentList.forEach(o -> ebt.add(o.getEbt()));
        List<BigDecimal> normal = getNormal(ebt);

        //全国当前插入
        for (int i = 0; i < ebt.size(); i++) {
            jxsRepProfitDistribute = new JxsRepProfitDistribute();
            jxsRepProfitDistribute.setId(getUUID());//ID
            jxsRepProfitDistribute.setYearId(yearId);//年份
            jxsRepProfitDistribute.setQuarterId(quarterId);//季度
            jxsRepProfitDistribute.setRangeType(4);
            jxsRepProfitDistribute.setStatisType(1);
            jxsRepProfitDistribute.setXCoordinate(currentList.get(i).getEbt());
            jxsRepProfitDistribute.setYCoordinate(normal.get(i));

            resultList.add(jxsRepProfitDistribute);
        }

        ebt.clear();
        totalList.forEach(o -> ebt.add(o.getEbt()));
        List<BigDecimal> normalTotal = getNormal(ebt);

        //全国累计插入
        for (int i = 0; i < ebt.size(); i++) {
            jxsRepProfitDistribute = new JxsRepProfitDistribute();
            jxsRepProfitDistribute.setId(getUUID());//ID
            jxsRepProfitDistribute.setYearId(yearId);//年份
            jxsRepProfitDistribute.setQuarterId(quarterId);//季度
            jxsRepProfitDistribute.setRangeType(4);
            jxsRepProfitDistribute.setStatisType(0);
            jxsRepProfitDistribute.setXCoordinate(totalList.get(i).getEbt());
            jxsRepProfitDistribute.setYCoordinate(normalTotal.get(i));

            resultList.add(jxsRepProfitDistribute);
        }

        //大区当前插入
        ebt.clear();
        currentList.stream().filter(o -> "东区".equals(o.getJxsRegionId())).forEach(x -> ebt.add(x.getEbt()));
        List<BigDecimal> normalEast = getNormal(ebt);
        for (int i = 0; i < ebt.size(); i++) {
            jxsRepProfitDistribute = new JxsRepProfitDistribute();
            jxsRepProfitDistribute.setId(getUUID());//ID
            jxsRepProfitDistribute.setYearId(yearId);//年份
            jxsRepProfitDistribute.setQuarterId(quarterId);//季度
            jxsRepProfitDistribute.setRangeType(3);
            jxsRepProfitDistribute.setStatisType(1);
            jxsRepProfitDistribute.setJxsRegionId("e662790a-c722-11ea-b945-7b7148722317");
            jxsRepProfitDistribute.setXCoordinate(ebt.get(i));
            jxsRepProfitDistribute.setYCoordinate(normalEast.get(i));

            resultList.add(jxsRepProfitDistribute);
        }
        ebt.clear();
        currentList.stream().filter(o -> "南区".equals(o.getJxsRegionId())).forEach(x -> ebt.add(x.getEbt()));
        List<BigDecimal> normalSouth = getNormal(ebt);
        for (int i = 0; i < ebt.size(); i++) {
            jxsRepProfitDistribute = new JxsRepProfitDistribute();
            jxsRepProfitDistribute.setId(getUUID());//ID
            jxsRepProfitDistribute.setYearId(yearId);//年份
            jxsRepProfitDistribute.setQuarterId(quarterId);//季度
            jxsRepProfitDistribute.setRangeType(3);
            jxsRepProfitDistribute.setStatisType(1);
            jxsRepProfitDistribute.setJxsRegionId("e6633c5f-c722-11ea-b945-7b7148722317");
            jxsRepProfitDistribute.setXCoordinate(ebt.get(i));
            jxsRepProfitDistribute.setYCoordinate(normalSouth.get(i));

            resultList.add(jxsRepProfitDistribute);
        }
        ebt.clear();
        currentList.stream().filter(o -> "西区".equals(o.getJxsRegionId())).forEach(x -> ebt.add(x.getEbt()));
        List<BigDecimal> normalWest = getNormal(ebt);
        for (int i = 0; i < ebt.size(); i++) {
            jxsRepProfitDistribute = new JxsRepProfitDistribute();
            jxsRepProfitDistribute.setId(getUUID());//ID
            jxsRepProfitDistribute.setYearId(yearId);//年份
            jxsRepProfitDistribute.setQuarterId(quarterId);//季度
            jxsRepProfitDistribute.setRangeType(3);
            jxsRepProfitDistribute.setStatisType(1);
            jxsRepProfitDistribute.setJxsRegionId("e6636371-c722-11ea-b945-7b7148722317");
            jxsRepProfitDistribute.setXCoordinate(ebt.get(i));
            jxsRepProfitDistribute.setYCoordinate(normalWest.get(i));

            resultList.add(jxsRepProfitDistribute);
        }
        ebt.clear();
        currentList.stream().filter(o -> "北区".equals(o.getJxsRegionId())).forEach(x -> ebt.add(x.getEbt()));
        List<BigDecimal> normalNorth = getNormal(ebt);
        for (int i = 0; i < ebt.size(); i++) {
            jxsRepProfitDistribute = new JxsRepProfitDistribute();
            jxsRepProfitDistribute.setId(getUUID());//ID
            jxsRepProfitDistribute.setYearId(yearId);//年份
            jxsRepProfitDistribute.setQuarterId(quarterId);//季度
            jxsRepProfitDistribute.setRangeType(3);
            jxsRepProfitDistribute.setStatisType(1);
            jxsRepProfitDistribute.setJxsRegionId("e663154c-c722-11ea-b945-7b7148722317");
            jxsRepProfitDistribute.setXCoordinate(ebt.get(i));
            jxsRepProfitDistribute.setYCoordinate(normalNorth.get(i));

            resultList.add(jxsRepProfitDistribute);
        }
//        ebt.clear();
//        currentList.stream().filter(o -> "中区".equals(o.getJxsRegionId())).forEach(x -> ebt.add(x.getEbt()));
//        List<BigDecimal> normalCentre = getNormal(ebt);
//        for (int i = 0; i < ebt.size(); i++) {
//            jxsRepProfitDistribute = new JxsRepProfitDistribute();
//            jxsRepProfitDistribute.setId(getUUID());//ID
//            jxsRepProfitDistribute.setYearId(yearId);//年份
//            jxsRepProfitDistribute.setQuarterId(quarterId);//季度
//            jxsRepProfitDistribute.setRangeType(3);
//            jxsRepProfitDistribute.setStatisType(1);
//            jxsRepProfitDistribute.setJxsRegionId("e662a01b-c722-11ea-b945-7b7148722317");
//            jxsRepProfitDistribute.setXCoordinate(ebt.get(i));
//            jxsRepProfitDistribute.setYCoordinate(normalCentre.get(i));
//
//            resultList.add(jxsRepProfitDistribute);
//        }

        //大区累计插入
        ebt.clear();
        totalList.stream().filter(o -> "东区".equals(o.getJxsRegionId())).forEach(x -> ebt.add(x.getEbt()));
        List<BigDecimal> normaEastTotal = getNormal(ebt);
        for (int i = 0; i < ebt.size(); i++) {
            jxsRepProfitDistribute = new JxsRepProfitDistribute();
            jxsRepProfitDistribute.setId(getUUID());//ID
            jxsRepProfitDistribute.setYearId(yearId);//年份
            jxsRepProfitDistribute.setQuarterId(quarterId);//季度
            jxsRepProfitDistribute.setRangeType(3);
            jxsRepProfitDistribute.setStatisType(0);
            jxsRepProfitDistribute.setJxsRegionId("e662790a-c722-11ea-b945-7b7148722317");
            jxsRepProfitDistribute.setXCoordinate(ebt.get(i));
            jxsRepProfitDistribute.setYCoordinate(normaEastTotal.get(i));

            resultList.add(jxsRepProfitDistribute);
        }
        ebt.clear();
        totalList.stream().filter(o -> "南区".equals(o.getJxsRegionId())).forEach(x -> ebt.add(x.getEbt()));
        List<BigDecimal> normaSouthTotal = getNormal(ebt);
        for (int i = 0; i < ebt.size(); i++) {
            jxsRepProfitDistribute = new JxsRepProfitDistribute();
            jxsRepProfitDistribute.setId(getUUID());//ID
            jxsRepProfitDistribute.setYearId(yearId);//年份
            jxsRepProfitDistribute.setQuarterId(quarterId);//季度
            jxsRepProfitDistribute.setRangeType(3);
            jxsRepProfitDistribute.setStatisType(0);
            jxsRepProfitDistribute.setJxsRegionId("e6633c5f-c722-11ea-b945-7b7148722317");
            jxsRepProfitDistribute.setXCoordinate(ebt.get(i));
            jxsRepProfitDistribute.setYCoordinate(normaSouthTotal.get(i));

            resultList.add(jxsRepProfitDistribute);
        }
        ebt.clear();
        totalList.stream().filter(o -> "西区".equals(o.getJxsRegionId())).forEach(x -> ebt.add(x.getEbt()));
        List<BigDecimal> normaWestTotal = getNormal(ebt);
        for (int i = 0; i < ebt.size(); i++) {
            jxsRepProfitDistribute = new JxsRepProfitDistribute();
            jxsRepProfitDistribute.setId(getUUID());//ID
            jxsRepProfitDistribute.setYearId(yearId);//年份
            jxsRepProfitDistribute.setQuarterId(quarterId);//季度
            jxsRepProfitDistribute.setRangeType(3);
            jxsRepProfitDistribute.setStatisType(0);
            jxsRepProfitDistribute.setJxsRegionId("e6636371-c722-11ea-b945-7b7148722317");
            jxsRepProfitDistribute.setXCoordinate(ebt.get(i));
            jxsRepProfitDistribute.setYCoordinate(normaWestTotal.get(i));

            resultList.add(jxsRepProfitDistribute);
        }
        ebt.clear();
        totalList.stream().filter(o -> "北区".equals(o.getJxsRegionId())).forEach(x -> ebt.add(x.getEbt()));
        List<BigDecimal> normaNorthTotal = getNormal(ebt);
        for (int i = 0; i < ebt.size(); i++) {
            jxsRepProfitDistribute = new JxsRepProfitDistribute();
            jxsRepProfitDistribute.setId(getUUID());//ID
            jxsRepProfitDistribute.setYearId(yearId);//年份
            jxsRepProfitDistribute.setQuarterId(quarterId);//季度
            jxsRepProfitDistribute.setRangeType(3);
            jxsRepProfitDistribute.setStatisType(0);
            jxsRepProfitDistribute.setJxsRegionId("e663154c-c722-11ea-b945-7b7148722317");
            jxsRepProfitDistribute.setXCoordinate(ebt.get(i));
            jxsRepProfitDistribute.setYCoordinate(normaNorthTotal.get(i));

            resultList.add(jxsRepProfitDistribute);
        }
//        ebt.clear();
//        totalList.stream().filter(o -> "中区".equals(o.getJxsRegionId())).forEach(x -> ebt.add(x.getEbt()));
//        List<BigDecimal> normaCentreTotal = getNormal(ebt);
//        for (int i = 0; i < ebt.size(); i++) {
//            jxsRepProfitDistribute = new JxsRepProfitDistribute();
//            jxsRepProfitDistribute.setId(getUUID());//ID
//            jxsRepProfitDistribute.setYearId(yearId);//年份
//            jxsRepProfitDistribute.setQuarterId(quarterId);//季度
//            jxsRepProfitDistribute.setRangeType(3);
//            jxsRepProfitDistribute.setStatisType(0);
//            jxsRepProfitDistribute.setJxsRegionId("e662a01b-c722-11ea-b945-7b7148722317");
//            jxsRepProfitDistribute.setXCoordinate(ebt.get(i));
//            jxsRepProfitDistribute.setYCoordinate(normaCentreTotal.get(i));
//
//            resultList.add(jxsRepProfitDistribute);
//        }


        try {
            databaseDao.deleteJxsRepProfitDistribute(yearId, quarterId);
            databaseDao.insertJxsRepProfitDistribute(resultList);

        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }

    }

    @Override
    public void handleJxsWriteStatis(String yearId, String quarterId, List<DealerForm> dealerList, Map<String, Object> carMap,
                                     Map<String, Object> usedMap, Map<String, Object> saleMap, Map<String, Object> globalMap) throws Exception {

        List<JxsWriteStatis> resultList = new ArrayList<>();

        GlobalIndex globalIndex = new GlobalIndex();
        NewCarIndex newCarIndex = new NewCarIndex();
        AfterSaleIndex afterSaleIndex = new AfterSaleIndex();

        ArrayList<GlobalIndex> globalDealer = (ArrayList<GlobalIndex>) globalMap.get("总体_经销商");
        ArrayList<NewCarIndex> carDealer = (ArrayList<NewCarIndex>) carMap.get("新车_经销商");
        ArrayList<AfterSaleIndex> saleDealer = (ArrayList<AfterSaleIndex>) saleMap.get("售后_经销商");

        List<CoreIndexEnum> enumList = Stream.of(CoreIndexEnum.values()).collect(Collectors.toList());

        List<Object> objlist = Arrays.asList(globalDealer, globalDealer, globalDealer, globalDealer, globalDealer, globalDealer, globalDealer, globalDealer,
                globalDealer, carDealer, carDealer, carDealer, carDealer, carDealer, carDealer, saleDealer, saleDealer, saleDealer, saleDealer, saleDealer,
                saleDealer, saleDealer, saleDealer, saleDealer, saleDealer, saleDealer, carDealer, carDealer, carDealer, globalDealer, globalDealer);

        List<Object> entityList = Arrays.asList(globalIndex, globalIndex, globalIndex, globalIndex, globalIndex, globalIndex, globalIndex, globalIndex,
                globalIndex, newCarIndex, newCarIndex, newCarIndex, newCarIndex, newCarIndex, newCarIndex, afterSaleIndex, afterSaleIndex, afterSaleIndex,
                afterSaleIndex, afterSaleIndex, afterSaleIndex, afterSaleIndex, afterSaleIndex, afterSaleIndex, afterSaleIndex, afterSaleIndex, newCarIndex,
                newCarIndex, newCarIndex, globalIndex, globalIndex);

        List<String> indexList = Arrays.asList("综合营业收入", "税前净利润平均单店", "税前净利润率", "一级毛利", "一级毛利率", "二级毛利", "二级毛利率", "三级毛利", "三级毛利率",
                "平均单店新车毛利Ⅰ", "新车一级毛利率", "平均单店新车毛利Ⅱ", "新车二级毛利率", "平均单店新车毛利Ⅲ", "三级毛利率", "平均单店售后毛利Ⅰ", "售后GPⅠ", "平均单店售后毛利Ⅱ",
                "售后二级毛利率", "平均单店售后毛利Ⅲ", "售后三级毛利率", "售后一级毛利率", "平均单店售后产值", "售后进厂台次平均单店", "售后单车产值", "售后吸收率", "精品加装渗透率",
                "消费信贷渗透率", "新车保险渗透率", "各项经营费用总计", "费用率");//费用总计费用率

        JxsWriteStatis jxsWriteStatis;
        for (int i = 0; i < enumList.size(); i++) {
            for (int j = 0; j < dealerList.size(); j++) {
                jxsWriteStatis = new JxsWriteStatis();
                jxsWriteStatis.setId(getUUID());//ID
                jxsWriteStatis.setYearId(yearId);//年份
                jxsWriteStatis.setQuarterId(quarterId);//季度
                jxsWriteStatis.setRangeType(0);//rangeType
                jxsWriteStatis.setJxsDealerId(dealerList.get(j).getJxsDealerId());
                jxsWriteStatis.setStatisTypeId(enumList.get(i).getStatisId());
                jxsWriteStatis.setContTypeId(enumList.get(i).getContTypeId());
                jxsWriteStatis.setTargetId(enumList.get(i).getTargetId());
                if (i < 9) {
                    ArrayList<GlobalIndex> temp = (ArrayList<GlobalIndex>) objlist.get(i);
                    setAttr(temp.get(j), entityList.get(i));
                } else if (i < 15) {
                    ArrayList<NewCarIndex> temp = (ArrayList<NewCarIndex>) objlist.get(i);
                    setAttr(temp.get(j), entityList.get(i));
                } else if (i < 26) {
                    ArrayList<AfterSaleIndex> temp = (ArrayList<AfterSaleIndex>) objlist.get(i);
                    setAttr(temp.get(j), entityList.get(i));
                } else if (i < 29) {
                    ArrayList<NewCarIndex> temp = (ArrayList<NewCarIndex>) objlist.get(i);
                    setAttr(temp.get(j), entityList.get(i));
                } else {
                    ArrayList<GlobalIndex> temp = (ArrayList<GlobalIndex>) objlist.get(i);
                    setAttr(temp.get(j), entityList.get(i));
                }

                jxsWriteStatis.setTaegetVal(getValue(entityList.get(i), indexList.get(i)));
                resultList.add(jxsWriteStatis);
            }
        }

        try {
            databaseDao.deleteJxsWriteStatis(yearId, quarterId);
            databaseDao.insertJxsWriteStatis(resultList);

        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }

    }

    /*
     * @Description Entity动态get
     * @Param [obj, name]
     * @return java.math.BigDecimal
     * @Author admin
     * @Date 2021/3/26
     */
    private static BigDecimal getValue(Object obj, String name) {
        try {
            Method m = (Method) obj.getClass().getMethod(("get" + name));
            if (m.invoke(obj) != null) {
                BigDecimal bigDecimal = new BigDecimal(m.invoke(obj).toString());
                return bigDecimal;
            } else {
                return null;
            }


        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
        return null;
    }
    /*
     * @Description 设置实体属性obj1给obj2赋值
     * @Param [class1, class2]
     * @return void
     * @Author admin
     * @Date 2021/3/26
     */
    public static void setAttr(Object class1, Object class2) throws Exception {
        Class clazz1 = class1.getClass();
        Class clazz2 = class2.getClass();
        Field[] fields1 = clazz1.getDeclaredFields();
        Field[] fields2 = clazz2.getDeclaredFields();
        for (Field f1 : fields1) {
            if ("id".equals(f1.getName())) {
                continue;
            }
            f1.setAccessible(true);
            Object value = f1.get(class1);
            for (Field f2 : fields2) {
                if (f1.getName().equals(f2.getName())) {
                    f2.setAccessible(true);
                    f2.set(class2, value);
                }
            }
        }
    }

    /*
     * @Description 正态分布图
     * @Param [EBT]
     * @return java.util.List<java.math.BigDecimal>
     * @Author admin
     * @Date 2021/3/26
     */
    public static List<BigDecimal> getNormal(List<BigDecimal> EBT) {
        BigDecimal up = new BigDecimal(EBT.stream().collect(Collectors.summingDouble(x -> x.doubleValue())).toString());

        BigDecimal mean = up.divide(BigDecimal.valueOf(EBT.size()), 4, BigDecimal.ROUND_HALF_EVEN);

        BigDecimal std = new BigDecimal("0");

        for (BigDecimal bigDecimal : EBT) {
            std = std.add(
                    bigDecimal.subtract(mean).multiply(bigDecimal.subtract(mean))
            );
        }
        std = std.divide(BigDecimal.valueOf(EBT.size()), 4, BigDecimal.ROUND_HALF_EVEN);


        BigDecimal pi = new BigDecimal(String.valueOf(Math.PI));


        BigDecimal param1 = new BigDecimal("1")
                .divide(BigDecimal.valueOf(Math.sqrt(pi.multiply(BigDecimal.valueOf(2).multiply(std)).doubleValue())), 4, BigDecimal.ROUND_HALF_EVEN);

        List<BigDecimal> paramList = new ArrayList<>();

        for (BigDecimal bigDecimal : EBT) {
            BigDecimal temp = param1.multiply(BigDecimal.valueOf(Math.exp(bigDecimal.subtract(mean)
                    .multiply(bigDecimal.subtract(mean))
                    .divide(std.multiply(BigDecimal.valueOf(2)), 4, BigDecimal.ROUND_HALF_EVEN).negate().doubleValue())));
            paramList.add(temp);

        }

        return paramList;

    }

    /*
     * @Description 获取分段经销商占比
     * @Param [tempList, dealerList, type]
     * @return java.util.List<java.math.BigDecimal>
     * @Author admin
     * @Date 2021/3/26
     */
    public List<BigDecimal> getPropList(List<JxsRepTotalInfo> tempList, List<DealerForm> dealerList, String type) {

        List<BigDecimal> result = new ArrayList<>();
        BigDecimal dealerCount;//经销商数量
        List<JxsRepTotalInfo> dealer;
        String rangeType4 = "全国";
        if (rangeType4.equals(type)) {
            dealerCount = BigDecimal.valueOf(dealerList.size());
            dealer = tempList;
        } else {
            dealerCount = BigDecimal.valueOf(dealerList.stream().filter(o -> o.getRegionName().equals(type)).count());
            dealer = tempList.stream().filter(o -> o.getJxsRegionId() != null && o.getJxsRegionId().equals(type)).collect(Collectors.toList());
        }


        result.add(BigDecimal.valueOf(
                dealer.stream().filter(o -> o.getRangeType().equals(0)
                        && o.getEbt().compareTo(new BigDecimal("-0.04")) == -1).count())
                .divide(dealerCount, 4, BigDecimal.ROUND_HALF_EVEN));

        result.add(BigDecimal.valueOf(
                dealer.stream().filter(o -> o.getRangeType().equals(0)
                        && o.getEbt().compareTo(new BigDecimal("-0.04")) > -1
                        && o.getEbt().compareTo(new BigDecimal("-0.02")) == -1).count())
                .divide(dealerCount, 4, BigDecimal.ROUND_HALF_EVEN));

        result.add(BigDecimal.valueOf(
                dealer.stream().filter(o -> o.getRangeType().equals(0)
                        && o.getEbt().compareTo(new BigDecimal("-0.02")) > -1
                        && o.getEbt().compareTo(new BigDecimal("0")) == -1).count())
                .divide(dealerCount, 4, BigDecimal.ROUND_HALF_EVEN));

        result.add(BigDecimal.valueOf(
                dealer.stream().filter(o -> o.getRangeType().equals(0)
                        && o.getEbt().compareTo(new BigDecimal("0")) > -1
                        && o.getEbt().compareTo(new BigDecimal("0.01")) == -1).count())
                .divide(dealerCount, 4, BigDecimal.ROUND_HALF_EVEN));

        result.add(BigDecimal.valueOf(
                dealer.stream().filter(o -> o.getRangeType().equals(0)
                        && o.getEbt().compareTo(new BigDecimal("0.01")) > -1
                        && o.getEbt().compareTo(new BigDecimal("0.02")) == -1).count())
                .divide(dealerCount, 4, BigDecimal.ROUND_HALF_EVEN));

        result.add(BigDecimal.valueOf(
                dealer.stream().filter(o -> o.getRangeType().equals(0)
                        && o.getEbt().compareTo(new BigDecimal("0.02")) > -1
                        && o.getEbt().compareTo(new BigDecimal("0.04")) == -1).count())
                .divide(dealerCount, 4, BigDecimal.ROUND_HALF_EVEN));

        result.add(BigDecimal.valueOf(
                dealer.stream().filter(o -> o.getRangeType().equals(0)
                        && o.getEbt().compareTo(new BigDecimal("0.04")) > -1).count())
                .divide(dealerCount, 4, BigDecimal.ROUND_HALF_EVEN));

        return result;
    }

    /*
     * @Description 随机数
     * @Param []
     * @return java.lang.Integer
     * @Author admin
     * @Date 2021/3/26
     */
    public Integer getSecureRandom() throws NoSuchAlgorithmException {
        Integer integer = Integer.parseInt(String.valueOf(SecureRandom.getInstance("SHA1PRNG").nextInt(999999999)).replace("-", ""));
        return integer;
    }

    /*
     * @Description UUID
     * @Param []
     * @return java.lang.String
     * @Author admin
     * @Date 2021/3/26
     */
    public String getUUID() {
        return UUID.randomUUID().toString();
    }

}
